Required Non-Null Arguments
  • For each Field or Directive in the document.
  • Let arguments be the arguments provided by the Field or Directive.
  • Let argumentDefinitions be the set of argument definitions of that Field or Directive.
  • For each definition in argumentDefinitions :
    • Let type be the expected type of definition .
    • If type is Non‐Null:
      • Let argumentName be the name of definition .
      • Let argument be the argument in arguments named argumentName
      • argument must exist.
      • Let value be the value of argument .
      • value must not be the null literal.

Explanatory Text

Arguments can be required. Arguments are required if the type of the argument is non‐null. If it is not non‐null, the argument is optional. When an argument type is non‐null, and is required, the explicit valuenullmay also not be provided.

For example the following are valid:

fragment goodBooleanArg on Arguments {
  booleanArgField(booleanArg: true)
}

fragment goodNonNullArg on Arguments {
  nonNullBooleanArgField(nonNullBooleanArg: true)
}

The argument can be omitted from a field with a nullable argument.

Therefore the following query is valid:

fragment goodBooleanArgDefault on Arguments {
  booleanArgField
}

but this is not valid on a non‐null argument.

fragment missingRequiredArg on Arguments {
  nonNullBooleanArgField
}

Providing the explicit valuenullis also not valid.

fragment missingRequiredArg on Arguments {
  notNullBooleanArgField(nonNullBooleanArg: null)
}

results matching ""

    No results matching ""