Giter Club home page Giter Club logo

Comments (5)

budde377 avatar budde377 commented on August 26, 2024

I haven't looked too much into it yet, but because you have these fragment spreads, try and add the addTypename option in your build config:

targets:
  $default:
    builders:
      graphql_codegen:
        options:
          addTypename: true
          clients:
            - graphql

from graphql_codegen.

vincenzopalazzo avatar vincenzopalazzo commented on August 26, 2024

I will try it later today, thanks

from graphql_codegen.

vincenzopalazzo avatar vincenzopalazzo commented on August 26, 2024

It just works, can you explain what is happening with this addTypename?

from graphql_codegen.

budde377 avatar budde377 commented on August 26, 2024

Yes, so because you're using fragments which are conditional on the type of the object it spreads, we need to provide a typename to let it know where to store the data. If it does not have this it'll assume that the fragment spread doesn't match the type and as such not store the data making it null.

The addTypename setting will add the __typename field selection to every object, giving the cache the best conditions to resolve this (together with possibleTypes).

I am considering making this enabled by default.

from graphql_codegen.

vincenzopalazzo avatar vincenzopalazzo commented on August 26, 2024

Cool thanks

I am considering making this enabled by default.

Cool be a good things to hide from the user view point IMO

from graphql_codegen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.