graphql-spec
graphql-spec copied to clipboard
allow directives on directive definitions
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
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:
We'd like to be able to declare directives on directive definitions.
We have tooling that uses type system directives to perform special processing on a schema, and we'd like users of that tooling to be able to define their own directives, with metadata indicating to the tooling that this directive is for its use. For example, if we could define
directive @Handler(class:String!) on DIRECTIVE_DEFINITION
then our users could definedirective @CustomDirective(...) on FIELD_DEFINITION @Handler(class:"Foo")
telling our tooling that their directive is meant to be handled by it, passing arguments we declare to our tooling, and still providing whatever arguments they declare to their own hooks.That directives can't be declared on directive definitions seems like an oversight.
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.
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