Package graphql.schema.idl
Interface SchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
-
- Type Parameters:
T
- the type of the object in play
- All Known Implementing Classes:
SchemaDirectiveWiringEnvironmentImpl
@PublicApi public interface SchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
SchemaDirectiveWiring
is passed this object as parameters when it builds out behaviour
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description boolean
containsDirective(java.lang.String directiveName)
Returns true if the named directive is presentGraphQLAppliedDirective
getAppliedDirective()
This returns the applied directive that theSchemaDirectiveWiring
was registered against during calls toRuntimeWiring.Builder.directive(String, SchemaDirectiveWiring)
GraphQLAppliedDirective
getAppliedDirective(java.lang.String directiveName)
Returns a named applied directive or nulljava.util.Map<java.lang.String,GraphQLAppliedDirective>
getAppliedDirectives()
java.util.Map<java.lang.String,java.lang.Object>
getBuildContext()
GraphQLCodeRegistry.Builder
getCodeRegistry()
GraphQLDirective
getDirective()
Deprecated.GraphQLDirective
getDirective(java.lang.String directiveName)
Deprecated.usegetAppliedDirective(String)
insteadjava.util.Map<java.lang.String,GraphQLDirective>
getDirectives()
Deprecated.usegetAppliedDirectives()
insteadT
getElement()
GraphqlElementParentTree
getElementParentTree()
The type hierarchy depends on the element in question.DataFetcher<?>
getFieldDataFetcher()
This is useful as a shortcut to get the current fields existing data fetcherGraphQLFieldDefinition
getFieldDefinition()
GraphQLFieldsContainer
getFieldsContainer()
NodeParentTree<NamedNode<?>>
getNodeParentTree()
The node hierarchy depends on the element in question.TypeDefinitionRegistry
getRegistry()
GraphQLFieldDefinition
setFieldDataFetcher(DataFetcher<?> newDataFetcher)
This is a shortcut method to set a new data fetcher in the underlyingGraphQLCodeRegistry
against the current field.
-
-
-
Method Detail
-
getElement
T getElement()
- Returns:
- the runtime element in play
-
getDirective
@Deprecated(since="2022-06-21") GraphQLDirective getDirective()
Deprecated.This returns the directive that theSchemaDirectiveWiring
was registered against during calls toRuntimeWiring.Builder.directive(String, SchemaDirectiveWiring)
If this method of registration is not used (say because
WiringFactory.providesSchemaDirectiveWiring(SchemaDirectiveWiringEnvironment)
orRuntimeWiring.Builder.directiveWiring(SchemaDirectiveWiring)
was used) then this will return null.- Returns:
- the directive that was registered under specific directive name or null if it was not registered this way
-
getAppliedDirective
GraphQLAppliedDirective getAppliedDirective()
This returns the applied directive that theSchemaDirectiveWiring
was registered against during calls toRuntimeWiring.Builder.directive(String, SchemaDirectiveWiring)
If this method of registration is not used (say because
WiringFactory.providesSchemaDirectiveWiring(SchemaDirectiveWiringEnvironment)
orRuntimeWiring.Builder.directiveWiring(SchemaDirectiveWiring)
was used) then this will return null.- Returns:
- the applied directive that was registered under specific directive name or null if it was not registered this way
-
getDirectives
@Deprecated(since="2022-06-21") java.util.Map<java.lang.String,GraphQLDirective> getDirectives()
Deprecated.usegetAppliedDirectives()
instead- Returns:
- all of the directives that are on the runtime element
-
getDirective
@Deprecated(since="2022-06-21") GraphQLDirective getDirective(java.lang.String directiveName)
Deprecated.usegetAppliedDirective(String)
insteadReturns a named directive or null- Parameters:
directiveName
- the name of the directive- Returns:
- a named directive or null
-
getAppliedDirectives
java.util.Map<java.lang.String,GraphQLAppliedDirective> getAppliedDirectives()
- Returns:
- all of the directives that are on the runtime element
-
getAppliedDirective
GraphQLAppliedDirective getAppliedDirective(java.lang.String directiveName)
Returns a named applied directive or null- Parameters:
directiveName
- the name of the directive- Returns:
- a named directive or null
-
containsDirective
boolean containsDirective(java.lang.String directiveName)
Returns true if the named directive is present- Parameters:
directiveName
- the name of the directive- Returns:
- true if the named directive is present
-
getNodeParentTree
NodeParentTree<NamedNode<?>> getNodeParentTree()
The node hierarchy depends on the element in question. For exampleObjectTypeDefinition
nodes have no parent, however aArgument
might be on aFieldDefinition
which in turn might be on aObjectTypeDefinition
say- Returns:
- hierarchical graphql language node information
-
getElementParentTree
GraphqlElementParentTree getElementParentTree()
The type hierarchy depends on the element in question. For exampleGraphQLObjectType
elements have no parent, however aGraphQLArgument
might be on aGraphQLFieldDefinition
which in turn might be on aGraphQLObjectType
say- Returns:
- hierarchical graphql type information
-
getRegistry
TypeDefinitionRegistry getRegistry()
- Returns:
- the type registry
-
getBuildContext
java.util.Map<java.lang.String,java.lang.Object> getBuildContext()
- Returns:
- a mpa that can be used by implementors to hold context during the SDL build process
-
getCodeRegistry
GraphQLCodeRegistry.Builder getCodeRegistry()
- Returns:
- a builder of the current code registry builder
-
getFieldsContainer
GraphQLFieldsContainer getFieldsContainer()
- Returns:
- a
GraphQLFieldsContainer
when the element is contained with a fields container
-
getFieldDefinition
GraphQLFieldDefinition getFieldDefinition()
- Returns:
- a
GraphQLFieldDefinition
when the element is as field or is contained within one
-
getFieldDataFetcher
DataFetcher<?> getFieldDataFetcher()
This is useful as a shortcut to get the current fields existing data fetcher- Returns:
- a
DataFetcher
when the element is as field or is contained within one - Throws:
AssertException
- if there is not field in context at the time of the directive wiring callback
-
setFieldDataFetcher
GraphQLFieldDefinition setFieldDataFetcher(DataFetcher<?> newDataFetcher)
This is a shortcut method to set a new data fetcher in the underlyingGraphQLCodeRegistry
against the current field.Often schema directive wiring modify behaviour by wrapping or replacing data fetchers on fields. This method is a helper to make this easier in code.
- Parameters:
newDataFetcher
- the new data fetcher to use for this field- Returns:
- the environments
getFieldDefinition()
to allow for a more fluent code style - Throws:
AssertException
- if there is not field in context at the time of the directive wiring callback
-
-