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

Feat: Expose user-defined directives via introspection #3047

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

skywickenden
Copy link

Initial exploratory work to expose user-defined directives via introspection.

This is unfinished and once complete should be used to create an experimental branch rather than merge into master as this is not yet in the graphql-spec

It is being worked on to match the experimental features that have been published in the dotnet and java graphql implementations.

Resolves #2942

The below is taken from the Java implementation and demonstrates the final shape of the new appliedDirectives during introspection:

"An Applied Directive is an instances of a directive as applied to a schema element. This type is NOT specified by the graphql specification presently."
type __AppliedDirective {
  args: [__DirectiveArgument!]!
  name: String
}

"Directive arguments can have names and values.  The values are in graphql SDL syntax printed as a string. This type is NOT specified by the graphql specification presently."
type __DirectiveArgument {
  name: String!
  value: String
}

type __EnumValue {
  appliedDirectives: [__AppliedDirective!]!
  deprecationReason: String
  description: String
  isDeprecated: Boolean!
  name: String!
}

type __Field {
  appliedDirectives: [__AppliedDirective!]!
  args: [__InputValue!]!
  deprecationReason: String
  description: String
  isDeprecated: Boolean!
  name: String!
  type: __Type!
}

type __InputValue {
  appliedDirectives: [__AppliedDirective!]!
  defaultValue: String
  description: String
  name: String!
  type: __Type!
}

"A GraphQL Introspection defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, the entry points for query, mutation, and subscription operations."
type __Schema {
  appliedDirectives: [__AppliedDirective!]!
  description: String
  "'A list of all directives supported by this server."
  directives: [__Directive!]!
  "If this server supports mutation, the type that mutation operations will be rooted at."
  mutationType: __Type
  "The type that query operations will be rooted at."
  queryType: __Type!
  "'If this server support subscription, the type that subscription operations will be rooted at."
  subscriptionType: __Type
  "A list of all types supported by this server."
  types: [__Type!]!
}

type __Type {
  appliedDirectives: [__AppliedDirective!]!
  description: String
  enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
  fields(includeDeprecated: Boolean = false): [__Field!]
  inputFields: [__InputValue!]
  interfaces: [__Type!]
  kind: __TypeKind!
  name: String
  ofType: __Type
  possibleTypes: [__Type!]
  specifiedByUrl: String
}

Current status

__AppliedDirectives has been added to schema introspection requests. Its resolver needs developing to only include custom directives and to resolve an array of __DirectiveArgument for each __AppliedDirective

__DirectiveArgument and appliedDirectives on __Field, __EnumValue and __InputValue needs developing

@linux-foundation-easycla
Copy link

CLA Not Signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose user-defined meta-information via introspection API in form of directives
1 participant