urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.54k stars 444 forks source link

[@urql/exchange-graphcache] return null if a field is a union #3600

Closed lavolpecheprogramma closed 3 weeks ago

lavolpecheprogramma commented 1 month ago

Describe the bug

Hi, i have a problem with graphcache when the requested content contains a union field. i created a reproduction link, and here you can find the graphql schema

the query is

query ExampleQuery($slug: String) {
  GetUnionTest(slug: $slug) {
    id
    title
    unionField {
      ... on ReferenceModel {
        __typename
        id
        title
      }
      ... on AccessibleImage {
        __typename
        id
        alt
        image {
          metaData
          originalName
        }
      }
    }
  }
}

i published 2 contents queriable by slug: 'content-with-component' and 'content-with-reference' The network response is ok with the right content, but urql returns null.

Thanks in advance

Reproduction

https://stackblitz.com/edit/github-54uamg

Urql version

"@urql/exchange-graphcache": "^7.0.0", "@urql/vue": "^1.2.1",

Validations

lavolpecheprogramma commented 3 weeks ago

amazing work! thank you very much! @JoviDeCroock