dotansimha / dotansimha/graphql-code-generator
graphql 16 not supported
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Which packages are impacted by your issue?
@graphql-codegen/cli
### Describe the bug
Note - this is not a duplicate of #6937, this is to point out that issue is not actually complete.
The example in the docs does not work with graphql 16: https://the-guild.dev/graphql/codegen/docs/custom-codegen/using-visitor
The example *does* work if I downgrade to graphql 15.
Specifically this plugin example:
```ts
const { getCachedDocumentNodeFromSchema } = require('@graphql-codegen/plugin-helpers')
const { visit } = require('graphql')
module.exports = {
plugin(schema, documents, config) {
const astNode = getCachedDocumentNodeFromSchema(schema) // Transforms the GraphQLSchema into ASTNode
const visitor = {
FieldDefinition(node) {
// This function triggered per each field
},
ObjectTypeDefinition(node) {
// This function triggered per each type
}
}
const result = visit(astNode, { leave: visitor })
return result.definitions.join('\n')
}
}
```
Running this results in `visitFn.call is not a function`.
This is outlined in #6937, which is closed, but the issue persists as other recent comments on that issue indicate.
### Your Example Website or App
https://codesandbox.io/p/sandbox/headless-cloud-6z6r45
### Steps to Reproduce the Bug or Issue
1. Go to linked example
2. Run `npm run codegen` in the terminal
3. Observe output
### Expected behavior
Visitor function should not error.
### Screenshots or Videos

### Platform
- OS: multiple, n/a
- NodeJS: multiple, n/a
- `graphql` version: 16.6
- `@graphql-codegen/*` version(s): all latest, see sandbox
### Codegen Config File
See sandbox, copied from docs
### Additional context
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.