@PublicApi public class GraphQLDirective extends java.lang.Object implements GraphQLNamedSchemaElement
See http://graphql.org/learn/queries/#directives for more details on the concept.
A 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
and GraphQLArgument
classes to do both purposes. This was a modelling mistake. New GraphQLAppliedDirective
and GraphQLAppliedDirectiveArgument
classes have been introduced to better model when a directive is applied to a schema element,
as opposed to its schema definition itself.
Modifier and Type | Class and Description |
---|---|
static class |
GraphQLDirective.Builder |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHILD_ARGUMENTS |
Modifier and Type | Method and 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.
|
GraphQLArgument |
getArgument(java.lang.String name) |
java.util.List<GraphQLArgument> |
getArguments() |
java.util.List<GraphQLSchemaElement> |
getChildren() |
SchemaElementChildrenContainer |
getChildrenWithTypeReferences() |
DirectiveDefinition |
getDefinition()
The AST
Node 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.
|
boolean |
isNonRepeatable() |
boolean |
isRepeatable() |
static GraphQLDirective.Builder |
newDirective() |
static GraphQLDirective.Builder |
newDirective(GraphQLDirective existing) |
GraphQLAppliedDirective |
toAppliedDirective()
This method can be used to turn a directive that was being use as an applied directive into one.
|
java.lang.String |
toString() |
GraphQLDirective |
transform(java.util.function.Consumer<GraphQLDirective.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.
|
java.util.EnumSet<Introspection.DirectiveLocation> |
validLocations() |
GraphQLDirective |
withNewChildren(SchemaElementChildrenContainer newChildren) |
public static final java.lang.String CHILD_ARGUMENTS
public java.lang.String getName()
getName
in interface GraphQLNamedSchemaElement
public boolean isRepeatable()
public boolean isNonRepeatable()
public java.util.List<GraphQLArgument> getArguments()
public GraphQLArgument getArgument(java.lang.String name)
public java.util.EnumSet<Introspection.DirectiveLocation> validLocations()
public java.lang.String getDescription()
getDescription
in interface GraphQLNamedSchemaElement
public DirectiveDefinition getDefinition()
GraphQLNamedSchemaElement
Node
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 example GraphQLObjectType.getExtensionDefinitions()
getDefinition
in interface GraphQLNamedSchemaElement
public java.lang.String toString()
toString
in class java.lang.Object
public GraphQLDirective transform(java.util.function.Consumer<GraphQLDirective.Builder> builderConsumer)
builderConsumer
- the consumer code that will be given a builder to transformpublic GraphQLSchemaElement copy()
GraphQLSchemaElement
copy
in interface GraphQLSchemaElement
public TraversalControl accept(TraverserContext<GraphQLSchemaElement> context, GraphQLTypeVisitor visitor)
accept
in interface GraphQLSchemaElement
public java.util.List<GraphQLSchemaElement> getChildren()
getChildren
in interface GraphQLSchemaElement
public SchemaElementChildrenContainer getChildrenWithTypeReferences()
getChildrenWithTypeReferences
in interface GraphQLSchemaElement
public GraphQLDirective withNewChildren(SchemaElementChildrenContainer newChildren)
withNewChildren
in interface GraphQLSchemaElement
public GraphQLAppliedDirective toAppliedDirective()
GraphQLAppliedDirective
public final boolean equals(java.lang.Object o)
equals
in interface GraphQLSchemaElement
equals
in class java.lang.Object
o
- the reference object with which to compare.true
if this object is the same as the obj
argument; false
otherwise.public final int hashCode()
hashCode
in interface GraphQLSchemaElement
hashCode
in class java.lang.Object
public static GraphQLDirective.Builder newDirective()
public static GraphQLDirective.Builder newDirective(GraphQLDirective existing)