@PublicApi public class GraphQLArgument extends java.lang.Object implements GraphQLNamedSchemaElement, GraphQLInputValueDefinition
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 |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHILD_DIRECTIVES |
static java.lang.String |
CHILD_TYPE |
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<GraphQLSchemaElement> context,
GraphQLTypeVisitor visitor) |
java.util.List<GraphQLSchemaElement> |
getChildren() |
SchemaElementChildrenContainer |
getChildrenWithTypeReferences() |
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()
The AST
Node this schema element is based on. |
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.
|
GraphQLArgument |
withNewChildren(SchemaElementChildrenContainer newChildren) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDirective, getDirectivesByName
public static final java.lang.String CHILD_DIRECTIVES
public static final java.lang.String CHILD_TYPE
@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 GraphQLNamedSchemaElement
public GraphQLInputType getType()
getType
in interface GraphQLInputValueDefinition
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()
getDescription
in interface GraphQLNamedSchemaElement
public InputValueDefinition 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.util.List<GraphQLDirective> getDirectives()
getDirectives
in interface GraphQLDirectiveContainer
public java.util.List<GraphQLSchemaElement> getChildren()
getChildren
in interface GraphQLSchemaElement
public SchemaElementChildrenContainer getChildrenWithTypeReferences()
getChildrenWithTypeReferences
in interface GraphQLSchemaElement
public GraphQLArgument withNewChildren(SchemaElementChildrenContainer newChildren)
withNewChildren
in interface GraphQLSchemaElement
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<GraphQLSchemaElement> context, GraphQLTypeVisitor visitor)
accept
in interface GraphQLSchemaElement
public java.lang.String toString()
toString
in class java.lang.Object