Skip to content

Allow merging nullable and non-null fields #1204

@ornamental

Description

@ornamental

It is widely believed that, in the process of schema evolution, changing field type from T to T! is not a breaking change.
A counter-example is given below (a like of it was encountered in a real-life application).

Consider the following [partial] schema

union ExternalResource = LinkedResource | ResourceCitation

type LinkedResource {
  title: String!
  link: String
}

type ResourceCitation {
  citation: String!
  link: String
}

and this selection set

{
  ... on LinkedResource {
    link
  }
  ... on ResourceCitation {
    link
  }
}

The selection set is valid (FieldsInSetCanMerge returns true on it).
Suppose the schema evolves:

type LinkedResource {
  title: String!
  link: String!
}

The selection set given above is now invalid, since SameResponseShape (step 3a) returns false.

Since T! is naturally embedded in T, it seems reasonable to allow such 'compatible' fields to be queried without forcing aliasing upon API clients (and possibly causing a breaking change where, semantically, there is none).

The problem looks related to these recently opened issues:
#1171
#1169

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