Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add rfc for resolve directive #1416

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jensneuse
Copy link
Member

No description provided.

In addition, I propose a new directive `@resolve` which allows us to define a query on an input field.
This input field can be market as `@inaccessible` to prevent exposing it to the public API.
As such, clients are not able to define the input field in their queries.
Instead, the Router will execute the query defined in the `@resolve` directive and pass the result to the input.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@resolve only makes sense as a name if we intend this functionality for several use cases.

In this RFC, what is actually being conducted is a prerequisite or a prevalidation.

id: ID!
name: String! @requires(fields: "info")
email: String! @requires(fields: "info")
info: UserInfo @inaccessible @resolve(query: "query { info: userInfo { id name email }}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here, User.info is delegating to @resolve, which is calling Query.userInfo? Although I don't see any queries defined in this subgraph—does that mean the query can be defined anywhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if you can use any query defined anywhere, how do you make sure the mapping/relationship is correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can query the whole graph.
Composition needs to validate this query.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea overall. I have a couple of thoughts:

  1. There are use cases where you may want support for both a root query and a sibling query. We should simply have two separate arguments in the directive to allow for this. Something like:
scalar Variables # Maps to variables in the field set
scalar FieldSet # SelectionSet

directive @resolve(
  query: FieldSet, 
  queryVariables: Variables,
  fragment: FieldSet,
  fragmentVariables: Variables
)
  1. It would be great to ensure the atomicity of subgraphs that we have today. Today it's possible to have a subgraph at least generate and build itself independently. Your idea does still maintain that, but if we do change anything we should maintain this property.

Copy link

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Dec 24, 2024
@github-actions github-actions bot removed the Stale label Jan 8, 2025
Copy link

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants