graphql-java-kickstart/graphql-spring-boot

Spring Boot Graphql Remove duplicates from the Response

miriyalajanardhan opened this issue · 0 comments

How to remove the duplicates from the response of Graphql automatically

Lets see the below graphql request I have.

query {
  test1(request:{
            userId: "test1@test.com"
  }) {
       id
       name
       product
  }
}

And the Response is below:

{
    "data": {
        "test1": [{
                "id": 1,
                "name": "Test",
                "product": "ABCD"
            }, {
                "id": 1,
                "name": "Test",
                "product": "ABCD-2"
            },
        ]
    }
}

Now if I remove the "product" in the query response field, the reponse looks like below. That is where the duplicates come.

{
    "data": {
        "test1": [{
                "id": 1,
                "name": "Test"
            }, {
                "id": 1,
                "name": "Test"
            },
        ]
    }
}

Let me know if we have any library available to do this. We are using Spring Boot with below dependency.

<dependency>
    <groupId>com.graphql-java-kickstart</groupId>
    <artifactId>graphql-spring-boot-starter</artifactId>
    <version>14.1.0</version>
</dependency>