Customize field results
A field needs client-provided criteria such as an identifier, filter, or unit.
GraphQL · Class
GraphQL arguments are named inputs declared by fields or directives. They can be optional or required, may have defaults, and must use input types.
A GraphQL argument is a named input supplied to a field or directive to influence its result or behavior. Its schema definition specifies an input type and may mark the value as required or provide a default.
field(argumentName: InputType): ReturnTypeunit on a length field.query GetHuman($id: ID!, $size: Int) {
human(id: $id) {
name
profilePic(size: $size)
}
}A query supplies named arguments directly and factors dynamic values into variables.
A field needs client-provided criteria such as an identifier, filter, or unit.
A schema offers a sensible behavior when callers omit a nonessential option.
A query needs dynamic values supplied separately from its document.
Arguments are named inputs attached to fields or directives. A field can define zero or more of them, and each argument can alter the field's returned result.
Follow-up: Why are named arguments useful? They let a field accept several values without depending on positional ordering, so adding or rearranging arguments remains clearer and less error-prone.
An argument is required when its type is non-null; otherwise it is optional. An optional argument may define a default value that is used when the client omits it.
Follow-up: What happens when a non-null argument is omitted? Validation rejects the operation because the required argument has no supplied value.
Arguments must use input types. GraphQL fields may receive arguments at every nesting level, and variables provide a separate dictionary for dynamic argument values.
Follow-up: Why use variables instead of embedding dynamic values? Variables separate changing data from the query document and can be supplied through the transport request.
Schemas and TypesArgumentsFieldsInput Object typesQueriesVariablesExecution