Skip to content
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

Using genql for server side (resolver) typing #128

Open
dnz-bdeboer opened this issue Jun 5, 2023 · 1 comment
Open

Using genql for server side (resolver) typing #128

dnz-bdeboer opened this issue Jun 5, 2023 · 1 comment

Comments

@dnz-bdeboer
Copy link

It looks like genql can be used for inserting proper types when writing the actual resolvers too, instead of just client side. However the support isn't great.

In an AWS amplify world I get types I can use as follows:

import { AppSyncResolverEvent } from "aws-lambda"
import { Maybe, MutationFooArgs, Foo } from "../generated/graphql"

export const foo = async (
  event: AppSyncResolverEvent<MutationFooArgs>
): Promise<Maybe<Foo>> => {
  ...
}

With genql the best I could do was something like:

import { AppSyncResolverEvent } from "aws-lambda"
import { MutationGenqlSelection, Mutation } from "../generated/genql/schema"

export const foo = async (
  event: AppSyncResolverEvent<MutationGenqlSelection["foo"]["__args"]["input"]>
): Promise<Mutation["foo"]> => {
  ...
}

This is harder to write and get correct as autocomplete doesn't work well here it seems.

Could genql create some types that would work better in the backend?

@remorses
Copy link
Owner

remorses commented Jun 5, 2023

Genql is not built for this use case, it's better if you use the previous types generator for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants