Field level resolver makes the field disappear from TS typegen
See original GitHub issueHi. I want to store 1-many relation in an array which contains ids to related objects. orders: [123, 456, 789]
And then I want that field level resolver to grab related objects but as soon as i add resolver function the field disappears and TS raises an error saying field does not exist on type. Relevant image:
For example having only type:
type: list("Order")
does not remove the field from TS typegen but as soon as resolve func is added, the field is gone.
What’s the problem here? Am i misunderstanding something?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Return incomplete shapes from resolver with GraphQL Code ...
When I have these sorts of scenarios, I make the extra field nullable (replace extra: UserExtra! with extra: UserExtra ).
Read more >Upgrading from Prisma 1 with prisma-binding to Nexus
This file will contain the type of your context object that's passed through your GraphQL resolver chain. Create the new context.ts file inside...
Read more >What is generated? — TypeGen 2.5.2 documentation
Both properties and fields will be generated to TypeScript, unless marked with TsIgnore attribute. Fields are always declared before properties in the ...
Read more >@slonik/typegen - npm Package Health Analysis | Snyk
We found a way for you to contribute to the project! Looks like @slonik/typegen is missing a security policy. You can connect your...
Read more >type-graphql/Lobby - Gitter
Does the value used as its TS type or explicit type is decorated with a ... there a way to access arguments given...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yeah, this has been a longstanding source of confusion. The original intention of Nexus is that you’re providing a way to resolve your “source types” globally: https://nexusjs.org/docs/guides/source-types#globally-configure-source-types
I use a fork of schemats for this. If
source
/parent
is an object that’s an ORM class, then you’d want a way to know it’s that object and not a vanilla JS object. I use a codegen of the database with a fork of schemats for this, but for simpler types or if you don’t want/need to do this, it should be possible to manage this on the object’s field definition.I’m thinking maybe we add a convenience helper for this,
sourceType
?sourceType: true
- preservesourceType: 'string | number', etc
- specify custom typingIf
true
it will preserve whatever the typing would otherwise be for the field based on the definition, so in this case:@jasonkuhrt thoughts?
Is there any news on this? Because if I use:
sourceType: { module: __filename, export: 'UserShape' }
The type is correctly imported in the generated types file but since I use this file in the front-end I don’t have access to the import.