Skip to content

Merged GraphQL fragments only use one selection #28133

Description

@AlexGaillard

Describe the Bug

When using multiple GQL fragments in a query that target the same collection, the fields are merged and only the selections of the first query survive the merge.

To Reproduce

  • Create a collection pages
  • Add a field title: string
  • Run a GQL query with merged fragments:
fragment A on Query { page { id } }
fragment B on Query { page { title } }
query { ...A ...B }
  • Result only returns id
{
  "data": {
    "page": [
      {
        "id": "1",
        "title": null
      },
      {
        "id": "2",
        "title": null
      }
    ]
  }
}

Directus Version

12.3.0

Hosting Strategy

Self-Hosted (Docker Image)

Database

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