-
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
Some thoughts compared to graphqlgen #740
Comments
Regarding number 3 I suggest you to have a look at the It allows you to define the following schema:
It will generate the following types:
So you can use |
Hi @benawad
Each field has it's own type that looks like this: export type PostResolver<R = Post | null, Parent = any, Context = any> = Resolver<R, Parent, Context>; So you can: const postResolver: PostResolver<string>; |
@darkbasic thanks, I'll check it out that looks good @kamilkisiela sweet |
Thank you @benawad ! Regarding 1, @kamilkisiela already did a fix for it: #741 . We loved this feedback but actually thought to take it a step further and to use Regarding 2, As @kamilkisiela said, we have support for this use case, any you can override it easily. If you wish to change the default value, we added support for this in this PR: #743 Regarding 3, as @kamilkisiela mentioned above, you can override every type because we are using generics in the generated resolvers and we think it’s a nicer solution to that issue. The changes I mentioned above are in
|
@dotansimha I'm using dataloader to batch requests, so it will only be 1 db call to fetch all the posts. Would you suggest taking a different approach? |
@benawad If you are using dataloader to batch requests then it's great :) Then your resolver should expect to get then full object and not just the id, but the linked resolvers should return Then you should be able to use the generics to override the return value of each resolver, and set it to Also, @kamilkisiela added a |
So I just tried out https://github.com/prisma/graphqlgen and this library with the following template: graphql-codegen-typescript-template to create Typescript types for resolvers.
I wanted to give some feedback on some things I liked better about graphqlgen.
If a query/mutation doesn’t have any arguments, graphqlgen generates the args Typescript type as
{}
which I like better than the template which usesany
.graphqlgen let’s me set what the
Context
type is upfront, so I don’t have to doQueryResolvers.Resolvers<Context>
, I can just doQueryResolvers.Resolvers
.I’m not sure how to handle this case:
So my schema is this:
So in the
post
resolver it expects me to return anauthor
, but I really want to return aauthorId
and have thePost.author
resolver use theauthorId
to fetch and return anauthor
. graphqlgen solves this by allowing you to create your own typescript types and it will use those.The text was updated successfully, but these errors were encountered: