-
Notifications
You must be signed in to change notification settings - Fork 116
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
base: main
Are you sure you want to change the base?
Conversation
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. |
There was a problem hiding this comment.
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 }}") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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:
- 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
)
- 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.
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
No description provided.