-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typescript-resolvers] Allow passing parent types to Resolvers
#5517
Comments
@graphql-codegen/typescript-resolvers
] Allow passing parent types to Resolvers
Resolvers
Resolvers
Resolvers
At the moment we have to use |
@migueloller this sounds like a very useful idea. What do you think about creating a PR? |
@dotansimha, I've been meaning to respond to this for a while now. Sorry for the delay! I would love to contribute with a PR, but unfortunately I'm quite busy at my job right now. |
Any update on this? |
I can't help with a PR right now, but maybe an example of an OSS project that successfully does something similar could help? Here's how Slate, a rich text editing library achieves this with interface declaration merging: https://docs.slatejs.org/concepts/12-typescript#defining-editor-element-and-text-types The original discussion can be seen here: ianstormtaylor/slate#3725 My suggestion here is to do it via generics, but the result is the same: the ability to extend and customize the types. |
Problem
We use this wonderful tool together with
@graphql-utilities/schema
to generate type safe mocks for our UI component stories. In those stories, we've given developers the ability to mock the GraphQL schema by passing in resolvers. These resolvers might have different parent types depending on what the developer is presenting in the story. At the moment, it's only possible to generate resolver types with specific parent types or overridable parent types viaallowParentTypeOverride
. Unfortunately, this means that each resolver needs to have types added, though. Also, allowParentTypeOverride is just for the generics and doesn't change the valid types that can be returned from a resolver and one might want to return a different type like when using mappers.Solution/Request
It would be great if when using
Resolvers
we could passResolversParentTypes
. It would look something like this:Internally,
Resolvers
would replace the parent types given and fall back to the current behavior when a type is missing. This could be done like this:A similar change would be needed for type resolvers where the mappers are also able to be inferred from this second generic of
Resolvers
The text was updated successfully, but these errors were encountered: