Skip to content

Ignore unknown fields in input object for mutation #1240

@zeng-alt

Description

@zeng-alt

Background

I'm using spring-graphql with strict input types like UserInput, PolicyRuleInput, etc. On the frontend, we often add extra fields to objects for local state tracking (e.g., timestamp, __typename), which are not part of the schema.

When we submit a mutation like saveUser, it fails with:

Validation error ... contains a field not in 'UserInput': 'timestamp'

Feature Request

It would be helpful to have an option that allows unknown fields in the input to be ignored during validation, or be stripped before binding. For example:

graphql:
  validation:
    ignore-extra-fields: true

Rationale

This aligns with practical frontend workflows (especially in Apollo), where local fields are used for caching and UI state.

Alternative

Right now, we manually strip fields like __typename, timestamp, etc., before submitting mutations. But this is error-prone and repetitive.

Related Discussions

  • GraphQL spec strictly disallows unknown fields, but some GraphQL servers (like GraphQL Yoga) provide an "ignore unknown fields" mode.
  • Could this be made optional behind a config or annotation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions