zino-hofmann / graphql-flutter

A GraphQL client for Flutter, bringing all the features from a modern GraphQL client to one easy to use package.
https://zino-hofmann.github.io/graphql-flutter
MIT License
3.24k stars 612 forks source link

Unable to use "Subscription" as a __typename value #1319

Closed andrewescutia closed 1 year ago

andrewescutia commented 1 year ago

When 'Subscription' is used as a __typename, the caching mechanism confuses it for the operation type and doesn't properly cache the list of items. This is done during the normalization efforts of the response so I'm uncertain if this would fall under this project or the Normalize package.

It also appears that this was an issue within the Apollo Client that was deemed appropriate and corrected: https://github.com/apollographql/apollo-client/issues/6911

example query:

query {  
     viewer {  
    user {
      subscriptions {
        __typename
        items {
          __typename
        }
      }
    }
  }
}

example response

{
  "data": {
    "viewer": {
      "user": {
        "subscriptions": {
          "__typename": "Subscriptions",
          "items": [
            {
              "__typename": "Subscription",
              "name": "Andrew"
            },
            {
              "__typename": "Subscription",
              "name": "Bob"
            }
          ]
        }
      }
    }
  }
}

the data looks something like this after re-read from cache.

{
  "user": {
    "subscriptions": {
      "items": [
        {
          "name": "Bob"
        },
        {
          "name": "Bob"
        }
      ]
    }
  }
}
andrewescutia commented 1 year ago

moving issue over to https://github.com/gql-dart/ferry