-
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
can't use __typename inside async function #3610
Comments
@kamilkisiela can you please take a look? |
@dotansimha I don't think there's something we could do... It's TypeScript that has no idea how to compare a string with an actual value. adding @moun3iim In your example, if you set This type of annotation is called @dotansimha another solution but more "painful" to developers could be to let |
@kamilkisiela we can generate const assertions in base |
I can't understand, should I edit "LoginResponse" in the generated file !! |
@moun3iim no, you should add it to the code you are writing :) const signInWithEmail: MutationResolvers["signInWithEmail"] = async () => {
return {
__typename: "LoginResponse" as const, // < here
token: "token"
}
} |
Looks like this is no longer working with TS 4.0.2–using |
It makes sense, since it marks the function as real |
Fair questions @dotansimha — I think my issue is unrelated to the issue described here. I'm going to open up a new ticket with a repro. :) |
Describe the bug
I get Type error when I try to use
__typename
insideasync
functionbut here when I add
async
I get the errorThe error
codegen.yml
config file:Expected behavior
Environment:
"@graphql-codegen/cli": "^1.12.2"
"@graphql-codegen/typescript": "1.12.2"
"@graphql-codegen/typescript-resolvers": "^1.12.2"
The text was updated successfully, but these errors were encountered: