Package graphql.schema.idl
Class SchemaDirectiveWiringEnvironmentImpl<T extends GraphQLDirectiveContainer>
- java.lang.Object
-
- graphql.schema.idl.SchemaDirectiveWiringEnvironmentImpl<T>
-
- All Implemented Interfaces:
SchemaDirectiveWiringEnvironment<T>
public class SchemaDirectiveWiringEnvironmentImpl<T extends GraphQLDirectiveContainer> extends java.lang.Object implements SchemaDirectiveWiringEnvironment<T>
-
-
Constructor Summary
Constructors Constructor Description SchemaDirectiveWiringEnvironmentImpl(T element, java.util.List<GraphQLDirective> directives, java.util.List<GraphQLAppliedDirective> appliedDirectives, GraphQLAppliedDirective registeredAppliedDirective, GraphQLDirective registeredDirective, graphql.schema.idl.SchemaGeneratorDirectiveHelper.Parameters parameters)
-
Method Summary
All Methods Instance Methods Concrete 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()
This returns the directive that theSchemaDirectiveWiring
was registered against during calls toRuntimeWiring.Builder.directive(String, SchemaDirectiveWiring)
GraphQLDirective
getDirective(java.lang.String directiveName)
Returns a named directive or nulljava.util.Map<java.lang.String,GraphQLDirective>
getDirectives()
T
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.
-
-
-
Constructor Detail
-
SchemaDirectiveWiringEnvironmentImpl
public SchemaDirectiveWiringEnvironmentImpl(T element, java.util.List<GraphQLDirective> directives, java.util.List<GraphQLAppliedDirective> appliedDirectives, GraphQLAppliedDirective registeredAppliedDirective, GraphQLDirective registeredDirective, graphql.schema.idl.SchemaGeneratorDirectiveHelper.Parameters parameters)
-
-
Method Detail
-
getElement
public T getElement()
- Specified by:
getElement
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- the runtime element in play
-
getDirective
public GraphQLDirective getDirective()
Description copied from interface:SchemaDirectiveWiringEnvironment
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.- Specified by:
getDirective
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- the directive that was registered under specific directive name or null if it was not registered this way
-
getAppliedDirective
public GraphQLAppliedDirective getAppliedDirective()
Description copied from interface:SchemaDirectiveWiringEnvironment
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.- Specified by:
getAppliedDirective
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- the applied directive that was registered under specific directive name or null if it was not registered this way
-
getDirectives
public java.util.Map<java.lang.String,GraphQLDirective> getDirectives()
- Specified by:
getDirectives
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- all of the directives that are on the runtime element
-
getDirective
public GraphQLDirective getDirective(java.lang.String directiveName)
Description copied from interface:SchemaDirectiveWiringEnvironment
Returns a named directive or null- Specified by:
getDirective
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Parameters:
directiveName
- the name of the directive- Returns:
- a named directive or null
-
getAppliedDirectives
public java.util.Map<java.lang.String,GraphQLAppliedDirective> getAppliedDirectives()
- Specified by:
getAppliedDirectives
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- all of the directives that are on the runtime element
-
getAppliedDirective
public GraphQLAppliedDirective getAppliedDirective(java.lang.String directiveName)
Description copied from interface:SchemaDirectiveWiringEnvironment
Returns a named applied directive or null- Specified by:
getAppliedDirective
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Parameters:
directiveName
- the name of the directive- Returns:
- a named directive or null
-
containsDirective
public boolean containsDirective(java.lang.String directiveName)
Description copied from interface:SchemaDirectiveWiringEnvironment
Returns true if the named directive is present- Specified by:
containsDirective
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Parameters:
directiveName
- the name of the directive- Returns:
- true if the named directive is present
-
getNodeParentTree
public NodeParentTree<NamedNode<?>> getNodeParentTree()
Description copied from interface:SchemaDirectiveWiringEnvironment
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- Specified by:
getNodeParentTree
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- hierarchical graphql language node information
-
getRegistry
public TypeDefinitionRegistry getRegistry()
- Specified by:
getRegistry
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- the type registry
-
getBuildContext
public java.util.Map<java.lang.String,java.lang.Object> getBuildContext()
- Specified by:
getBuildContext
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- a mpa that can be used by implementors to hold context during the SDL build process
-
getCodeRegistry
public GraphQLCodeRegistry.Builder getCodeRegistry()
- Specified by:
getCodeRegistry
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- a builder of the current code registry builder
-
getFieldsContainer
public GraphQLFieldsContainer getFieldsContainer()
- Specified by:
getFieldsContainer
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- a
GraphQLFieldsContainer
when the element is contained with a fields container
-
getElementParentTree
public GraphqlElementParentTree getElementParentTree()
Description copied from interface:SchemaDirectiveWiringEnvironment
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- Specified by:
getElementParentTree
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- hierarchical graphql type information
-
getFieldDefinition
public GraphQLFieldDefinition getFieldDefinition()
- Specified by:
getFieldDefinition
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- a
GraphQLFieldDefinition
when the element is as field or is contained within one
-
getFieldDataFetcher
public DataFetcher<?> getFieldDataFetcher()
Description copied from interface:SchemaDirectiveWiringEnvironment
This is useful as a shortcut to get the current fields existing data fetcher- Specified by:
getFieldDataFetcher
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Returns:
- a
DataFetcher
when the element is as field or is contained within one
-
setFieldDataFetcher
public GraphQLFieldDefinition setFieldDataFetcher(DataFetcher<?> newDataFetcher)
Description copied from interface:SchemaDirectiveWiringEnvironment
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.
- Specified by:
setFieldDataFetcher
in interfaceSchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Parameters:
newDataFetcher
- the new data fetcher to use for this field- Returns:
- the environments
SchemaDirectiveWiringEnvironment.getFieldDefinition()
to allow for a more fluent code style
-
-