Giter Site home page Giter Site logo

Comments (3)

zhouzi avatar zhouzi commented on May 18, 2024

Good catch, thanks.

Ideally I'd like not to have the code be based on the __typename field as I know some developers completely disable it through other plugins' option. But then I don't know how to extract a type from an union.

With #45 the use of Extract will be limited to unions instead of being used as soon as there's a type condition. And perhaps we can add a note in the documentation that nonOptionalTypename must be set to true if the developer is using unions. We could throw an error as well if the plugin tries to generate a union factory when this option is not set to true.

What do you think? Would that be acceptable?

from graphql-codegen-factories.

zhouzi avatar zhouzi commented on May 18, 2024

I've been thinking about this issue and I may have found a solution that doesn't require developers to change their configuration:

- Extract<BlogListQueryQuery, { __typename: 'Query' }>
+ Extract<BlogListQueryQuery & { __typename: NonNullable<BlogListQueryQuery["__typename"]> }, { __typename: 'Query' }>

from graphql-codegen-factories.

zhouzi avatar zhouzi commented on May 18, 2024

This has been fixed by #45 and will be published with a 1.0.0.

from graphql-codegen-factories.

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.