From 2ec6970aef4fd70a948a5a12b88fd7d2aec76157 Mon Sep 17 00:00:00 2001 From: geisterfurz007 Date: Sun, 17 Sep 2023 15:38:26 +0200 Subject: [PATCH] fix: custom visitor documentation --- .../src/pages/docs/custom-codegen/using-visitor.mdx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/website/src/pages/docs/custom-codegen/using-visitor.mdx b/website/src/pages/docs/custom-codegen/using-visitor.mdx index 5c3257605b4..2bae6f9aaba 100644 --- a/website/src/pages/docs/custom-codegen/using-visitor.mdx +++ b/website/src/pages/docs/custom-codegen/using-visitor.mdx @@ -52,8 +52,7 @@ module.exports = { Then, create your initial visitor, in our case, we would like to transform a `FieldDefinition` and `ObjectTypeDefinition`, so let's create an object with a stub definitions, an use `visit` to run it: ```js {8-13} -const { getCachedDocumentNodeFromSchema } = require('@graphql-codegen/plugin-helpers') -const { visit } = require('graphql') +const { getCachedDocumentNodeFromSchema, oldVisit } = require('@graphql-codegen/plugin-helpers') module.exports = { plugin(schema, documents, config) { @@ -67,7 +66,7 @@ module.exports = { } } - const result = visit(astNode, { leave: visitor }) + const result = oldVisit(astNode, { leave: visitor }) return result.definitions.join('\n') } @@ -77,8 +76,7 @@ module.exports = { Now, let's implement `ObjectTypeDefinition` and `FieldDefinition`: ```js {8-15} -const { getCachedDocumentNodeFromSchema } = require('@graphql-codegen/plugin-helpers') -const { visit } = require('graphql') +const { getCachedDocumentNodeFromSchema, oldVisit } = require('@graphql-codegen/plugin-helpers') module.exports = { plugin(schema, documents, config) { @@ -94,7 +92,7 @@ module.exports = { } } - const result = visit(astNode, { leave: visitor }) + const result = oldVisit(astNode, { leave: visitor }) return result.definitions.join('\n') }