Comments (3)
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.
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.
This has been fixed by #45 and will be published with a 1.0.0
.
from graphql-codegen-factories.
Related Issues (20)
- Operations plugin does not include fields from fragments HOT 9
- Nested factories for the operations plugin HOT 4
- Setup a realistic demo example HOT 4
- Use a better support for the documentation
- Add example on how to use with faker (or equivalent)
- Add a readme to the examples and list them on the website
- Generate factories for the fragments HOT 2
- Make the overrides optional HOT 4
- Accept nested partials HOT 1
- Document factories with JSDoc HOT 1
- schemaFactoriesPath should not resolve to local path when it starts with a tilde
- Union factory has type error in certain scenarios
- Warn when a factory would lead to an infinite loop HOT 6
- Add option to initialize nullables, instead of setting them to null HOT 4
- Add maybeValueDefault to customize the default value for nullables
- Omit optional properties by default? HOT 1
- compatability with `add` plugin HOT 5
- using `graphql-codegen-factories/operations` fails on `this.schema.getRootType` HOT 10
- Naming issues with custom Query root type HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-codegen-factories.