Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a resolver for existing GraphQL schema in type-graphql?

Tags:

typegraphql

When I work on a graphql project, I like the type-graphql way: use classes and decorators to create GraphQL schemas.

But now I have a problem: we need to use some GraphQL schemas which are defined from another package. They don't use type-graphql, and provided some schema objects of GraphQLObjectType.

In type-graphql resolvers, it seems like we have to use the classes we defined by type-graphql decorators.

Is it possible to make them work together? How to write a resolver for existing GraphQL schema in type-graphql?

like image 895
Freewind Avatar asked Jan 19 '26 19:01

Freewind


1 Answers

You can try to use some utils to merge the schemas:

https://github.com/Urigo/merge-graphql-schemas

TypeGraphQL was not designed to dynamically add fields to existing object types which are graphql-js constructs, not a class with proper types.

like image 181
Michał Lytek Avatar answered Jan 23 '26 21:01

Michał Lytek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!