Package graphql.schema.idl
Interface SchemaDirectiveWiringEnvironment<T extends GraphQLDirectiveContainer>
- Type Parameters:
T- the type of the object in play
- All Known Implementing Classes:
SchemaDirectiveWiringEnvironmentImpl
SchemaDirectiveWiring is passed this object as parameters
when it builds out behaviour-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsDirective(String directiveName) Returns true if the named directive is presentThis returns the applied directive that theSchemaDirectiveWiringwas registered against during calls toRuntimeWiring.Builder.directive(String, SchemaDirectiveWiring)getAppliedDirective(String directiveName) Returns a named applied directive or nullDeprecated.getDirective(String directiveName) Deprecated.usegetAppliedDirective(String)insteadDeprecated.usegetAppliedDirectives()insteadThe type hierarchy depends on the element in question.DataFetcher<?> This is useful as a shortcut to get the current fields existing data fetcherThe node hierarchy depends on the element in question.setFieldDataFetcher(DataFetcher<?> newDataFetcher) This is a shortcut method to set a new data fetcher in the underlyingGraphQLCodeRegistryagainst the current field.
-
Method Details
-
getElement
T getElement()- Returns:
- the runtime element in play
-
getDirective
Deprecated.This returns the directive that theSchemaDirectiveWiringwas 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 theSchemaDirectiveWiringwas 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.usegetAppliedDirectives()instead- Returns:
- all of the directives that are on the runtime element
-
getDirective
Deprecated.usegetAppliedDirective(String)insteadReturns a named directive or null- Parameters:
directiveName- the name of the directive- Returns:
- a named directive or null
-
getAppliedDirectives
Map<String,GraphQLAppliedDirective> getAppliedDirectives()- Returns:
- all of the directives that are on the runtime element
-
getAppliedDirective
Returns a named applied directive or null- Parameters:
directiveName- the name of the directive- Returns:
- a named directive or null
-
containsDirective
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 exampleObjectTypeDefinitionnodes have no parent, however aArgumentmight be on aFieldDefinitionwhich in turn might be on aObjectTypeDefinitionsay- Returns:
- hierarchical graphql language node information
-
getElementParentTree
GraphqlElementParentTree getElementParentTree()The type hierarchy depends on the element in question. For exampleGraphQLObjectTypeelements have no parent, however aGraphQLArgumentmight be on aGraphQLFieldDefinitionwhich in turn might be on aGraphQLObjectTypesay- Returns:
- hierarchical graphql type information
-
getRegistry
TypeDefinitionRegistry getRegistry()- Returns:
- the type registry
-
getBuildContext
- Returns:
- a map 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
GraphQLFieldsContainerwhen the element is contained with a fields container
-
getFieldDefinition
GraphQLFieldDefinition getFieldDefinition()- Returns:
- a
GraphQLFieldDefinitionwhen 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
DataFetcherwhen 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
This is a shortcut method to set a new data fetcher in the underlyingGraphQLCodeRegistryagainst 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
-
getAppliedDirective()