@PublicApi public class GraphQLArgument extends java.lang.Object implements GraphQLDirectiveContainer
GraphQLFieldDefinition
.
Fields can be thought of as "functions" that take arguments and return a value.
See http://graphql.org/learn/queries/#arguments for more details on the concept.
GraphQLArgument
is used in two contexts, one context is graphql queries where it represents the arguments that can be
set on a field and the other is in Schema Definition Language (SDL) where it can be used to represent the argument value instances
that have been supplied on a GraphQLDirective
.
The difference is the 'value' and 'defaultValue' properties. In a query argument, the 'value' is never in the GraphQLArgument
object but rather in the AST direct or in the query variables map and the 'defaultValue' represents a value to use if both of these are
not present. You can think of them like a descriptor of what shape an argument might have.
However with directives on SDL elements, the value is specified in AST only and transferred into the GraphQLArgument object and the
'defaultValue' comes instead from the directive definition elsewhere in the SDL. You can think of them as 'instances' of arguments, their shape and their
specific value on that directive.Modifier and Type | Class and Description |
---|---|
static class |
GraphQLArgument.Builder |
Constructor and Description |
---|
GraphQLArgument(java.lang.String name,
GraphQLInputType type)
Deprecated.
use the
newArgument() builder pattern instead, as this constructor will be made private in a future version. |
GraphQLArgument(java.lang.String name,
java.lang.String description,
GraphQLInputType type,
java.lang.Object defaultValue)
Deprecated.
use the
newArgument() builder pattern instead, as this constructor will be made private in a future version. |
GraphQLArgument(java.lang.String name,
java.lang.String description,
GraphQLInputType type,
java.lang.Object defaultValue,
InputValueDefinition definition)
Deprecated.
use the
newArgument() builder pattern instead, as this constructor will be made private in a future version. |
Modifier and Type | Method and Description |
---|---|
TraversalControl |
accept(TraverserContext<GraphQLType> context,
GraphQLTypeVisitor visitor)
Double-dispatch entry point.
|
java.util.List<GraphQLType> |
getChildren() |
java.lang.Object |
getDefaultValue()
An argument has a default value when it represents the logical argument structure that a
GraphQLFieldDefinition
can have and it can also have a default value when used in a schema definition language (SDL) where the
default value comes via the directive definition. |
InputValueDefinition |
getDefinition() |
java.lang.String |
getDescription() |
java.util.List<GraphQLDirective> |
getDirectives() |
java.lang.String |
getName() |
GraphQLInputType |
getType() |
java.lang.Object |
getValue()
An argument ONLY has a value when its used in a schema definition language (SDL) context as the arguments to SDL directives.
|
static GraphQLArgument.Builder |
newArgument() |
static GraphQLArgument.Builder |
newArgument(GraphQLArgument existing) |
java.lang.String |
toString() |
GraphQLArgument |
transform(java.util.function.Consumer<GraphQLArgument.Builder> builderConsumer)
This helps you transform the current GraphQLArgument into another one by starting a builder with all
the current values and allows you to transform it how you want.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDirective, getDirectivesByName
@Deprecated public GraphQLArgument(java.lang.String name, java.lang.String description, GraphQLInputType type, java.lang.Object defaultValue)
newArgument()
builder pattern instead, as this constructor will be made private in a future version.name
- the arg namedescription
- the arg descriptiontype
- the arg typedefaultValue
- the default value@Deprecated public GraphQLArgument(java.lang.String name, GraphQLInputType type)
newArgument()
builder pattern instead, as this constructor will be made private in a future version.name
- the arg nametype
- the arg typepublic GraphQLArgument(java.lang.String name, java.lang.String description, GraphQLInputType type, java.lang.Object defaultValue, InputValueDefinition definition)
newArgument()
builder pattern instead, as this constructor will be made private in a future version.name
- the arg namedescription
- the arg descriptiontype
- the arg typedefaultValue
- the default valuedefinition
- the AST definitionpublic java.lang.String getName()
getName
in interface GraphQLType
[_A-Za-z][_0-9A-Za-z]*
public GraphQLInputType getType()
public java.lang.Object getDefaultValue()
GraphQLFieldDefinition
can have and it can also have a default value when used in a schema definition language (SDL) where the
default value comes via the directive definition.public java.lang.Object getValue()
public java.lang.String getDescription()
public InputValueDefinition getDefinition()
public java.util.List<GraphQLDirective> getDirectives()
getDirectives
in interface GraphQLDirectiveContainer
public GraphQLArgument transform(java.util.function.Consumer<GraphQLArgument.Builder> builderConsumer)
builderConsumer
- the consumer code that will be given a builder to transformpublic static GraphQLArgument.Builder newArgument()
public static GraphQLArgument.Builder newArgument(GraphQLArgument existing)
public TraversalControl accept(TraverserContext<GraphQLType> context, GraphQLTypeVisitor visitor)
GraphQLType
Node
, see accept(...) for more details about the pattern.accept
in interface GraphQLType
context
- TraverserContext bound to this graphQL type objectvisitor
- Visitor instance that performs actual processing on the types(s)public java.util.List<GraphQLType> getChildren()
getChildren
in interface GraphQLType
public java.lang.String toString()
toString
in class java.lang.Object