Package graphql.introspection
Class IntrospectionWithDirectivesSupport
- java.lang.Object
-
- graphql.introspection.IntrospectionWithDirectivesSupport
-
@PublicApi public class IntrospectionWithDirectivesSupport extends java.lang.Object
The graphql specification does not allow you to retrieve the directives and their argument values that are present on types, enums, fields and input fields, so this class allows you to change the schema and enhance the Introspection types to contain this information. This allows you to get a directive say like `@example(argName : "someValue")` that is on a field or type at introspection time and act on it. This class takes a predicate that allows you to filter the directives you want to expose to the world. An `appliedDirectives` field is added and this contains extra fields that hold the directives and their applied values. For example the `__Field` type becomes as follows:type __Field { name: String! // other fields ... appliedDirectives: [_AppliedDirective!]! // NEW FIELD } type _AppliedDirective { // NEW INTROSPECTION TYPE name: String! args: [_DirectiveArgument!]! } type _DirectiveArgument { // NEW INTROSPECTION TYPE name: String! value: String! }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IntrospectionWithDirectivesSupport.DirectivePredicate
A callback which allows you to decide what directives may be included in introspection extensionsstatic interface
IntrospectionWithDirectivesSupport.DirectivePredicateEnvironment
The parameter environment on a call toIntrospectionWithDirectivesSupport.DirectivePredicate
-
Constructor Summary
Constructors Constructor Description IntrospectionWithDirectivesSupport()
This version lists all directives on a schema elementIntrospectionWithDirectivesSupport(IntrospectionWithDirectivesSupport.DirectivePredicate directivePredicate)
This version allows you to filter what directives are listed via the provided predicateIntrospectionWithDirectivesSupport(IntrospectionWithDirectivesSupport.DirectivePredicate directivePredicate, java.lang.String typePrefix)
This version allows you to filter what directives are listed via the provided predicate Some graphql systems (graphql-js in 2021) cannot cope with extra types starting with `__` so we use a `_` as a prefix by default.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GraphQLSchema
apply(GraphQLSchema schema)
This will transform the schema to have the new extension shapes
-
-
-
Constructor Detail
-
IntrospectionWithDirectivesSupport
public IntrospectionWithDirectivesSupport()
This version lists all directives on a schema element
-
IntrospectionWithDirectivesSupport
public IntrospectionWithDirectivesSupport(IntrospectionWithDirectivesSupport.DirectivePredicate directivePredicate)
This version allows you to filter what directives are listed via the provided predicate- Parameters:
directivePredicate
- the filtering predicate to decide what directives are shown
-
IntrospectionWithDirectivesSupport
public IntrospectionWithDirectivesSupport(IntrospectionWithDirectivesSupport.DirectivePredicate directivePredicate, java.lang.String typePrefix)
This version allows you to filter what directives are listed via the provided predicate Some graphql systems (graphql-js in 2021) cannot cope with extra types starting with `__` so we use a `_` as a prefix by default. You can supply your own prefix via this constructor. See: https://github.com/graphql-java/graphql-java/pull/2221 for more details- Parameters:
directivePredicate
- the filtering predicate to decide what directives are showntypePrefix
- the prefix to put on the new `AppliedDirectives` type
-
-
Method Detail
-
apply
public GraphQLSchema apply(GraphQLSchema schema)
This will transform the schema to have the new extension shapes- Parameters:
schema
- the original schema- Returns:
- the transformed schema with new extension types and fields in it for Introspection
-
-