graphql-spec icon indicating copy to clipboard operation
graphql-spec copied to clipboard

RFC: support returning applied directives as part of the introspection

Open JoviDeCroock opened this issue 1 year ago • 9 comments

The following proposes an addition to the introspection part of the spec. In every place where a directive can be applied we alter the corresponding type to have a list of __AppliedDirective present.

This would support use cases where we need additional information about the field to facilitate functionality like

  • @sensitive - to mask sensitive fields from logging information
  • @cache - to instruct an external system that a field is cacheable
  • in federation folks currently expose their whole SDL under a field so the central router can parse directives

This is already implement in the following implementations

  • GraphQL.NET
  • GraphQL Java

I tried making this as backwards compatible as possible, an alternative would be to rather than using name referring to the __Directive. Or if wanted we could include type with a reference to __Directive this does not seem present in the Java and .NET implementation.

I am aware of the limitation that String imposes as a type for the .value my main reasoning was that it's very much in line with defaultValue and shouldn't pose that much of an issue.

I am open to implementing this in the JS reference implementation as well.

Related to https://github.com/graphql/graphql-spec/issues/300

JoviDeCroock avatar Feb 07 '24 12:02 JoviDeCroock