-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which packages are impacted by your issue?
@graphql-codegen/cli
Describe the bug
Hey team, I just encountered this problem that graphql-codegen fails when an operation is located in a TypeScript file that contains the satisfies keyword. Upgrading all @graphql-codegen/* dependencies didn't help. Strangely enough, when I tried to reproduce with a fresh project, putting in the same plugins, configuration and the same TypeScript source code, it worked just fine.
Your Example Website or App
https://github.com/awx-doma-lei/graphql-codegen-cli-issue-repro
Steps to Reproduce the Bug or Issue
Run yarn codegen to see the error
Expected behavior
As a user, I expect graphql-codegen to work with my TypeScript files that uses the satisfies keyword.
Screenshots or Videos
No response
Platform
- OS: macOS
- NodeJS: 20.18.1
graphqlversion: 16.9.0@graphql-codegen/cliversion(s): 5.0.2, 5.0.7
Codegen Config File
No response
Additional context
Looking into the error stack, I noticed there's a Missing semicolon error from @babel/parser, and found that it's an earlier version of Babel (7.18.11 in my case) that doesn't support TypeScript 4.9 syntax (it's supported since Babel 7.20.0). But in the fresh project, the installed Babel was the latest, and that explained the issue.
Babel was depended on by @graphql-codegen/cli through the following chain:
@graphql-codegen/cli
-> @graphql-tools/{code-file-loader,git-loader,github-loader}
-> @graphql-tools/graphql-tag-pluck
-> @babel/parser
The reason that upgrading didn't work despite the latest @graphql-tools/graphql-tag-pluck already requires a higher version of Babel (7.26.0) since 8.3.18 was that the latest @graphql-codegen/cli's dependencies is still as tolerant as ^8.0.0, so @babel/parser didn't get updated when I upgraded @graphql-codegen/cli.
I think we should update @graphql-codegen/cli's package.json to require the newer versions of @graphql-tools/* dependencies to ensure a higher version of Babel and hence to ensure the support of TypeScript 4.9.