graphql-code-generator
graphql-code-generator copied to clipboard
Property 'enter' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> ...
Describe the bug
Getting the following build errors with TS:
node_modules/@graphql-codegen/plugin-helpers/oldVisit.d.ts:5:75 - error TS2339: Property 'enter' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> | undefined; readonly leave: ASTReducerFn<NameNode, unknown>; } | { readonly enter?: ASTVisitFn<DocumentNode> | undefined; readonly leave: ASTReducerFn<...>; } | ... 41 more ... | undefined'.
5 enter?: Partial<Record<keyof NewVisitor, NewVisitor[keyof NewVisitor]['enter']>>;
~~~~~~~
node_modules/@graphql-codegen/plugin-helpers/oldVisit.d.ts:6:75 - error TS2339: Property 'leave' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> | undefined; readonly leave: ASTReducerFn<NameNode, unknown>; } | { readonly enter?: ASTVisitFn<DocumentNode> | undefined; readonly leave: ASTReducerFn<...>; } | ... 41 more ... | undefined'.
6 leave?: Partial<Record<keyof NewVisitor, NewVisitor[keyof NewVisitor]['leave']>>;
To Reproduce
Use together:
"@graphql-codegen/plugin-helpers": "^2.4.1",
"graphql": "^16.3.0"
Then just importing it will trigger the bug:
import type { Types } from '@graphql-codegen/plugin-helpers';
- My GraphQL schema:
N/A
- My GraphQL operations:
N/A
- My
codegen.ymlconfig file:
N/A
Expected behavior
Not produce build errors.
Environment:
- OS: macOS
@graphql-codegen/plugin-helpers: 2.4.1- NodeJS: v14.17.6
Additional context
N/A
Hi @moltar
Thank you for your report!
Do you have any version of graphql installed globally?
If not, could you send here the portion of your lockfile (yarn or npm) that shows the graphql version resolution?
Thank you
Weird, nuked node_modules, and re-installed. Fixed the problem. ๐คท๐ผ
Do you have any version of graphql installed globally?
Good question.
Seems like no?
โฏ npm ls -g graphql
/Users/xyz/.fnm/node-versions/v14.17.6/installation/lib
โโโ (empty)
If not, could you send here the portion of your lockfile (yarn or npm) that shows the graphql version resolution?
Will do, if I can repro the issue again.
Most likely multiple versions of graphql were present in node_modules/ ๐
Will do, if I can repro the issue again.
Okay!
Ok, this is reproducible. Happens in GitHub Actions.
https://github.com/moltar/projen-graphql-codegen
https://github.com/moltar/projen-graphql-codegen/blob/e46a16399478a82f2b8da113419778b0789add86/yarn.lock#L2256-L2259
โฏ ag --json -r '"graphql"' node_modules
node_modules/@graphql-codegen/plugin-helpers/package.json
6: "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
node_modules/graphql/package.json
2: "name": "graphql",
30: "graphql",
node_modules/@graphql-tools/utils/package.json
7: "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
This GH Action fails:
https://github.com/moltar/projen-graphql-codegen/blob/9a0ccf85836dc8dc1282955363acd106a40b07fd/.github/workflows/release.yml#L18-L39
With:
๐พ release ยป build ยป default | ts-node --project tsconfig.dev.json .projenrc.ts
yarn install v1.22.17
[1/4] Resolving packages...
success Already up-to-date.
Done in 1.89s.
๐พ release ยป build ยป compile | tsc --build
node_modules/@graphql-codegen/plugin-helpers/oldVisit.d.ts(5,75): error TS2339: Property 'enter' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> | undefined; readonly leave: ASTReducerFn<NameNode, unknown>; } | { readonly enter?: ASTVisitFn<DocumentNode> | undefined; readonly leave: ASTReducerFn<...>; } | ... 41 more ... | undefined'.
node_modules/@graphql-codegen/plugin-helpers/oldVisit.d.ts(6,75): error TS2339: Property 'leave' does not exist on type '{ readonly enter?: ASTVisitFn<NameNode> | undefined; readonly leave: ASTReducerFn<NameNode, unknown>; } | { readonly enter?: ASTVisitFn<DocumentNode> | undefined; readonly leave: ASTReducerFn<...>; } | ... 41 more ... | undefined'.
๐พ Task "release ยป build ยป compile" failed when executing "tsc --build" (cwd: /home/runner/work/projen-graphql-codegen/projen-graphql-codegen)
Error: Process completed with exit code 1.
Switched to using NPM - same issue :/
Pinning to [email protected] seems to have worked ๐คท๐ผ
I'm having the same issue, I'm trying to use "@graphql-codegen/cli": "^2.6.2" with "graphql": "^16.5.0".
I made sure that "graphql": "^16.5.0" is the only version installed and that there is no global graphql version.
I also tried nuking the node_modules folder, but nothing helped.
It seems that there is a type mismatch between @graphql-codegen and graphql@16.
The latest @graphql-codegen version should support graphql v16, right?
Same issue
"@graphql-codegen/cli": "^2.6.2",
"graphql": "^16.3.0",
Extremely annoying. We must keep the codegen file in our repo commented out except for while its in use, else our typechecks will fail. skipLibCheck will fix it, but isnt something we want repo wide.
Any workarounds?
@sandromartis
The latest
@graphql-codegenversion should supportgraphqlv16, right?
Honestly, I am not sure about that. The dependency @graphql-codegen/visitor-plugin-common which is included in pretty much all plugins has two other dependencies that cause peer dependency warnings in Yarn:
@graphql-codegen/visitor-plugin-common > @graphql-tools/[email protected]" has incorrect peer dependency "graphql@^14.0.0 || ^15.0.0".
@graphql-codegen/visitor-plugin-common > [email protected]" has incorrect peer dependency "graphql@^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0".
Sadly I believe sticking to 15.8.0 is the safest option for now, but then again, I am not a contributor to this repo!
This error appeared on my project after importing accidentally this import.
import {EXACT_SIGNATURE} from "@graphql-codegen/typescript";
After deleting this the error was gone.
Weird, nuked
node_modules, and re-installed. Fixed the problem. ๐คท๐ผ
yes it helps