Closed szaim closed 1 month ago
Hi @szaim ,
At runtime, the parent's returned value will go into the parent
param of the Object type. Therefore, the two should match otherwise you may get runtime error.
Is it possible to configure graphql-codegen to type the parent parameter of a resolver with an internal type while keeping the default resolver return type?
Unfortunately, I haven't seen a use case for this. The current way preset works enforces the way GraphQL works - in my understanding - to help users avoid runtime errors. Are you observing something different in your application?
Also the codegen preset library am using it keeps overriding my field resolvers
Yes, this is expected to prevent users from using generated types incorrectly that could lead to type-safety issues.
Closing this as it is behaving as expected
In our graphql server there are essentially two types that exist in parallel.
Question Is it possible to configure graphql-codegen to type the parent parameter of a resolver with an internal type while keeping the default resolver return type? Also the codegen preset library am using it keeps overriding my field resolvers
I followed this example below and the typing inside the userResolver now works. However, the type of the userResolvers itself when used in the const resolvers that is typed with Resolvers is not assignable to User. So the type error is only shifted one level. Am I missing something here? :
and here is my codegen config