-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Missing import
statements in autogenerated files cause TypeScript errors
#2497
Comments
Getting the same issue on 1.7.0. Downgrading to 1.6.1 fixed the issue. (Hi Rafa!) |
Thanks @rafeca ! |
@rafeca @alexkirsz I think I fixed that in: #2524 By the way, we've just added a cool service called The Connected Build. We can connect your build system and tests to the codegen's own CI. That way we'll find those things on the PR itself and make sure you are always up to date (https://the-guild.dev/connected-build). This could help up prevent more of those in the future (on top of our current tests) |
Thanks for the quick response @dotansimha 😄 I've just tried |
@rafeca It's actually working in sandbox :)
Make sure to use |
Oh you're right, I forgot to add the caret on the dependency for the CodeSandbox 🙃 In my local project I'm still getting the same error though, I'm going to try to reproduce it in a codesandbox. |
Ok, here I have a repro: https://codesandbox.io/s/graphql-codegen-issue-template-fbe2g?fontsize=14&module=%2Fsrc%2Fpictures.generated.ts
fragment pictures on User {
pictures(limit: 10) {
nodes {
...picture
}
}
} |
This one works perfectly in our codebase! thanks a lot! 🤗 |
@dotansimha are you planning to release a new version of |
@rafeca I hope to release it today :) |
Fixed in 1.8.0 🚀 |
Describe the bug
On v1.7.0, the
near-operation-file
preset doesn't add the requiredimport
statement for the schema types in some situations, causing TypeScript errors.This seems to happen whenever an operation is not using any schema type directly, but the generator code still inserts
Types.Maybe
for nullable fields.This problem has been introduced in v1.7.0.
To Reproduce
Open the following CodeSandbox, where the issue is reproducible: https://codesandbox.io/s/graphql-codegen-issue-template-fbe2g?fontsize=14&module=%2Fsrc%2FgetUser.generated.ts
codegen.yml
config file:Expected behavior
I expect the generated files to not have any TypeScript error. The
getUser.generated.tsx
file has the following contents:(notice the missing
import * as types from "./graphql-schema-types.generated.ts";
).Environment:
@graphql-codegen
v1.7.0Additional context
The issue seems to have been caused by #2458
The text was updated successfully, but these errors were encountered: