Skip to content

Relational fields are duplicated in GraphQL API responseย #22456

Open
@atissedrescaleway

Description

Hello ๐Ÿ‘‹

Bug report

Required System information

  • Environment: development / production
  • OS: darwin-arm64
  • Strapi Version: 5.5.0
  • Node/Yarn Version: yarn/3.8.6 npm/? node/v20.11.1 darwin arm64
  • Edition: Community
  • Database: postgres
  • Typescript

Describe the bug

We've migrated from v4 to v5.5 a few days ago.

  • When using the GraphQL API, some entries (relational fields) are duplicated (same documentId, different id)
  • When using the REST Api, entries are not duplicated.

Steps to reproduce the behavior

  1. Create a "Speaker" collection and a "Speaker List" single-type.
  2. Add a relational field in Speaker List = Speaker List has many Speakers
  3. Create a new Speaker, publish it, add it to the Speaker List single-type, publish the single-type.
  4. Check the GraphQL playground response with the following query:
query ExampleQuery {
  speakerList {
    speakers {
      documentId
    }
  }
}
  1. Observe the duplicated response :
{
  "data": {
    "speakerList": {
      "speakers": [
        {
          "documentId": "nuxc57xqwt8tr6i9ut9894xw"
        },
        {
          "documentId": "nuxc57xqwt8tr6i9ut9894xw"
        }
      ]
    }
  }
}

Expected behavior

Response should not be duplicated and have only one document:

{
  "data": {
    "speakerList": {
      "speakers": [
        {
          "documentId": "nuxc57xqwt8tr6i9ut9894xw"
        },
      ]
    }
  }
}

Screenshots

image

image

Code snippets

If applicable, add code samples to help explain your problem.

Additional context

Dependencies of package.json :

"dependencies": {
    "@strapi/plugin-cloud": "5.5.2",
    "@strapi/plugin-graphql": "5.5.2",
    "@strapi/plugin-users-permissions": "5.5.2",
    "@strapi/provider-email-nodemailer": "5.5.2",
    "@strapi/provider-upload-aws-s3": "5.5.2",
    "@strapi/strapi": "5.5.2",
    "pg": "8.11.1",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-router-dom": "6.22.3",
    "styled-components": "6.1.8"
  },

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersissue: bugIssue reporting a bugseverity: mediumIf it breaks the basic use of the product but can be worked aroundsource: plugin:graphqlSource is plugin/graphql packagestatus: confirmedConfirmed by a Strapi Team member or multiple community membersversion: 5

    Type

    No type

    Projects

    • Status

      To be reviewed (Open)

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions