Skip to content

Default value compatibility validation is only specified for Object field arguments #1235

Description

@glen-84

PR #793 (Default value validation & coercion, September 2025 edition) added this rule to Objects → Type Validation:

5. If the argument has a default value it must be compatible with {argumentType} as per the coercion rules for that type.

However, the parallel rule is absent from the other locations where default values can be defined:

  • Interfaces → Type Validation: interface field arguments have no default-value compatibility rule (the argument rule list ends at IsInputType).
  • Input Objects → Type Validation: input fields have no compatibility rule for their default values (the section did gain the InputObjectDefaultValueHasCycle rule, but nothing requiring the default itself to be compatible with the field type).
  • Type System Directives → Type Validation: directive definition arguments have no default-value compatibility rule.

The reference implementation validates all four locations: graphql-js#3814 calls validateDefaultValue from validateFields (which runs for both Object and Interface types), validateInputFields, and validateDirectives — and removed a // TODO: validate default values? marker in the interface-implementation checks.

If the omission is unintentional, the fix seems editorial: add the same bullet to the Interfaces, Input Objects, and Type System Directives validation sections.

Drafted by Claude (Anthropic AI assistant).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions