Open
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:
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
- Go to linked example
- Run
npm run codegen
in the terminal - 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