Skip to content

Optimisation: remove duplicate merged fields from the operation document #5515

Closed as not planned
@tafelnl

Description

@tafelnl

Use case

Suppose we have this query:

query Users {
  users {
    ...someUserFragment
    ...otherUserFragment
  }
}

fragment someUserFragment on User {
  id
  firstName
  lastName
}

fragment otherUserFragment on User {
  id
  firstName
  dateOfBirth
}

It wouldn't necessarily be needed to send the id and firstName field defined in otherUserFragment to the server, as those fields are already defined inside the someUserFragment. The server would respond with the exact same response if we were to drop those fields on the otherUserFragment. So we can safely save a few bytes that way.

As an example, the above query could result in the following document after generating:

query Users {
  users {
    ...someUserFragment
    ...otherUserFragment
  }
}

fragment someUserFragment on User {
  id
  firstName
  lastName
}

fragment otherUserFragment on User {
  dateOfBirth
}

Describe the solution you'd like

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions