Package graphql.schema
Class GraphQLAppliedDirective
- java.lang.Object
-
- graphql.schema.GraphQLAppliedDirective
-
- All Implemented Interfaces:
GraphQLNamedSchemaElement
,GraphQLSchemaElement
@PublicApi public class GraphQLAppliedDirective extends java.lang.Object implements GraphQLNamedSchemaElement
An applied directive represents the instance of a directive that is applied to a schema element, as opposed to it definitionA directive has a definition, that is what arguments it takes, and it can also be applied to other schema elements. Originally graphql-java re-used the
GraphQLDirective
andGraphQLArgument
classes to do both purposes. This was a modelling mistake. NewGraphQLAppliedDirective
andGraphQLAppliedDirectiveArgument
classes have been introduced to better model when a directive is applied to a schema element, as opposed to its schema definition itself.See https://graphql.org/learn/queries/#directives for more details on the concept.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GraphQLAppliedDirective.Builder
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CHILD_ARGUMENTS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TraversalControl
accept(TraverserContext<GraphQLSchemaElement> context, GraphQLTypeVisitor visitor)
GraphQLSchemaElement
copy()
Each GraphQLSchemaElement should make a copy of itself when this is called.boolean
equals(java.lang.Object o)
No GraphQLSchemaElement implements `equals` because we need object identity to treat a GraphQLSchema as an abstract graph.GraphQLAppliedDirectiveArgument
getArgument(java.lang.String name)
java.util.List<GraphQLAppliedDirectiveArgument>
getArguments()
java.util.List<GraphQLSchemaElement>
getChildren()
SchemaElementChildrenContainer
getChildrenWithTypeReferences()
Directive
getDefinition()
The ASTNode
this schema element is based on.java.lang.String
getDescription()
java.lang.String
getName()
int
hashCode()
No GraphQLSchemaElement implements `equals/hashCode` because we need object identity to treat a GraphQLSchema as an abstract graph.static GraphQLAppliedDirective.Builder
newDirective()
static GraphQLAppliedDirective.Builder
newDirective(GraphQLAppliedDirective existing)
java.lang.String
toString()
GraphQLAppliedDirective
transform(java.util.function.Consumer<GraphQLAppliedDirective.Builder> builderConsumer)
This helps you transform the current GraphQLDirective into another one by starting a builder with all the current values and allows you to transform it how you want.GraphQLAppliedDirective
withNewChildren(SchemaElementChildrenContainer newChildren)
-
-
-
Field Detail
-
CHILD_ARGUMENTS
public static final java.lang.String CHILD_ARGUMENTS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceGraphQLNamedSchemaElement
- Returns:
- the name of this element. This cant be null
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescription
in interfaceGraphQLNamedSchemaElement
- Returns:
- the description of this element. This can be null
-
getArguments
public java.util.List<GraphQLAppliedDirectiveArgument> getArguments()
-
getArgument
public GraphQLAppliedDirectiveArgument getArgument(java.lang.String name)
-
getDefinition
public Directive getDefinition()
Description copied from interface:GraphQLNamedSchemaElement
The ASTNode
this schema element is based on. Is null if the GraphQLSchema is not based on a SDL document. Some elements also have additional extension Nodes. See for exampleGraphQLObjectType.getExtensionDefinitions()
- Specified by:
getDefinition
in interfaceGraphQLNamedSchemaElement
- Returns:
- Node which this element is based on. Can be null.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
transform
public GraphQLAppliedDirective transform(java.util.function.Consumer<GraphQLAppliedDirective.Builder> builderConsumer)
This helps you transform the current GraphQLDirective into another one by starting a builder with all the current values and allows you to transform it how you want.- Parameters:
builderConsumer
- the consumer code that will be given a builder to transform- Returns:
- a new field based on calling build on that builder
-
copy
public GraphQLSchemaElement copy()
Description copied from interface:GraphQLSchemaElement
Each GraphQLSchemaElement should make a copy of itself when this is called. The copy should be included its current contents as they currently exist into a new object.- Specified by:
copy
in interfaceGraphQLSchemaElement
- Returns:
- a copy of this element
-
accept
public TraversalControl accept(TraverserContext<GraphQLSchemaElement> context, GraphQLTypeVisitor visitor)
- Specified by:
accept
in interfaceGraphQLSchemaElement
-
getChildren
public java.util.List<GraphQLSchemaElement> getChildren()
- Specified by:
getChildren
in interfaceGraphQLSchemaElement
-
getChildrenWithTypeReferences
public SchemaElementChildrenContainer getChildrenWithTypeReferences()
- Specified by:
getChildrenWithTypeReferences
in interfaceGraphQLSchemaElement
-
withNewChildren
public GraphQLAppliedDirective withNewChildren(SchemaElementChildrenContainer newChildren)
- Specified by:
withNewChildren
in interfaceGraphQLSchemaElement
-
equals
public final boolean equals(java.lang.Object o)
No GraphQLSchemaElement implements `equals` because we need object identity to treat a GraphQLSchema as an abstract graph.- Specified by:
equals
in interfaceGraphQLSchemaElement
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- the reference object with which to compare.- Returns:
true
if this object is the same as the obj argument;false
otherwise.
-
hashCode
public final int hashCode()
No GraphQLSchemaElement implements `equals/hashCode` because we need object identity to treat a GraphQLSchema as an abstract graph.- Specified by:
hashCode
in interfaceGraphQLSchemaElement
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code value for this object.
-
newDirective
public static GraphQLAppliedDirective.Builder newDirective()
-
newDirective
public static GraphQLAppliedDirective.Builder newDirective(GraphQLAppliedDirective existing)
-
-