-
Notifications
You must be signed in to change notification settings - Fork 1.2k
allow directives on directive definitions #567
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
Conversation
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
|
Original feature request:
Please note that I'm a Googler and we're reviewing that we can sign the CLA. I don't anticipate a problem, but bear it in mind until we confirm. |
spawnia
left a comment
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.
Looks good to me, clean and easy.
We already have the counter example that disallows self-referencing directive definitions, so we should be clear there.
|
I would like to another use case that requires this change that might be a bit more common: Deprecation of directives. directive @foo on OBJECT @deprecated |
e5d241d to
6c81ed8
Compare
| ## Directives | ||
|
|
||
| DirectiveDefinition : Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations | ||
| DirectiveDefinition : Description? directive @ Name ArgumentsDefinition? on DirectiveLocations Directives[Const]? |
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.
One thing to consider is that this position would prevent future deprecation of one of the positions:
directive @foo on
| QUERY
| MUTATION @deprecated(reason: "Doesn't work well with side effects")
| SUBSCRIPTION
(I don't think this is particularly important, but it's worth noting.)
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.
You mean because the syntax would become ambiguous, right? I think I'm okay with this (famous last words 😅 )
|
As mentioned in the composite schemas WG, directives on directives could also simplify the current usage of Apollo Federation's # with directives on directives we could use simplified syntax
# naming of the compose directive is TBD
directive @custom on FIELD_DEFINITION @composeDirective
#### vs
# current compose directive logic requires explicit linking/importings on the schema element
extend schema @link(url: "http://fake.url/customSpec", import: ["@custom"])
@composeDirective(name: "@custom")
directive @custom on FIELD_DEFINITION |
|
We would love this in Apollo Kotlin because we'd like to deprecate certain client-side directives. @benhead I know this PR is almost 7 years old, but are you still interested in championing this change? I think this would be useful and shouldn’t be too controversial (famous last words 😅). From what I can tell, the PR also needs:
Then the next step is to implement it on graphql-js. |
|
Woops I didn't notice there was actually a more recent PR (2021) from @IvanGoncharov with the same proposal and with more conversation. I think it's fair to say this PR should be abandoned and any follow-up conversation should happen at #907. |
This is the minimum viable edit to enable this feature. I imagine we'd also want to allow directive extensions if this feature is approved.
#566