-
Notifications
You must be signed in to change notification settings - Fork 177
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
Build issues when using gql with ESM #804
Comments
Could you please create a TypeScript playground or reproduction project for that? |
Here's an example: Playground Link The error comes up as soon as you go into TS Config and change pretty much anything -- I set the Target to ES2022 for example and get the error immediately when the playground switched into ESM mode: This expression is not callable. |
@phryneas This should help: https://arethetypeswrong.github.io/?p=graphql-tag%402.12.6 |
@phryneas I've had the same issue for some time. I've hacked my way around it through a "postcodegen" npm script, but fixing the library exports would be preferable.
|
Building on @TimUnderhay's suggestion, I've noticed there's a import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
overwrite: true,
schema: "...",
documents: "...",
generates: {
"generated/types.ts": {
plugins: [
"typescript",
"typescript-operations",
//...
],
},
},
hooks: {
afterAllFileWrite: [
`sed -i '' "s/import gql from 'graphql-tag'/import { gql } from 'graphql-tag'/"`
],
},
};
export default config; |
I started running into this when trying to upgrade a react application to use esm (manually setup, no framework). I'm setup for SSR, so trying to run my project loads up
So I ultimately end up with an error like this:
This likely stems from loading the script via the I get that adding that directive might break things, but maybe instead of |
When using ESM,
gql
becomes non-callable because TS doesn't like namespaces with ESMindex.d.ts
file:I get this error:
Similar to dotansimha/graphql-code-generator-community#228
The text was updated successfully, but these errors were encountered: