Graphql multiple queries returns wrong data

Graphql multiple queries returns wrong data


0

I have a single grapqhl query that has multiple queries. The data returned is not correct as some of the data is mixed up. If I run the same query on graphql studio I get the desired data, however the data is wrong on the browser.

query GetCarFilters {
    getCarModelsWithCount {
        ...CarFilterFields
    }
    getCarMakesWithCarsCount {
        ...CarFilterFields
    }
    getCarFuelTypesWithCount {
        ...CarFilterFields
    }
    getCarColorsWithCount {
        ...CarFilterFields
    }
    getCarBodyTypesWithCount {
        ...CarFilterFields
    }
    getCarTransmissionWithCount {
        ...CarFilterFields
    }
}

This what I get from the getCarTransmissionWithCount on apollo studio

  "getCarTransmissionWithCount": [
      {
        "name": "Automatic",
        "id": 2,
        "count": 0
      },
      {
        "name": "Continuously Variable Transmission (CVT)",
        "id": 3,
        "count": 0
      },
      {
        "name": "Manual",
        "id": 1,
        "count": 3
      }
    ],
vs what I get on the browser
"getCarTransmissionWithCount":[
{
    "__typename": "CarFiltersWithCount",
    "name": "Hatchback",
    "id": 2,
    "count": 0
},
{
    "__typename": "CarFiltersWithCount",
    "name": "Coupe",
    "id": 3,
    "count": 0
},
{
    "__typename": "CarFiltersWithCount",
    "name": "Sedan",
    "id": 1,
    "count": 3
}

]
The content on the browser contains items from getCarBodyTypesWithCount.

Share
Improve this question

1

  • The discrepancy I was experiencing between the data returned in GraphQL Studio and the data in the browser was due to how Apollo Client handles caching and the data structure of your GraphQL queries. This behavior can occur when the query structure matches previous queries and Apollo Client attempts to reuse cached data.I changed fetchPolicy to no cache.

    – user12504353

    2 hours ago


Load 2 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *