From 85659bca1bdbd6d4a9a6e875acfbf9bb36056ea6 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 2 Feb 2023 11:48:32 +0100 Subject: [PATCH] fix: only warn about deprecated `introspectSchema` once (#5023) * fix: only warn about deprecated `introspectSchema` once * changeset --- .changeset/five-phones-pretend.md | 5 +++++ packages/wrap/src/introspect.ts | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/five-phones-pretend.md diff --git a/.changeset/five-phones-pretend.md b/.changeset/five-phones-pretend.md new file mode 100644 index 00000000000..3586e1c10ad --- /dev/null +++ b/.changeset/five-phones-pretend.md @@ -0,0 +1,5 @@ +--- +'@graphql-tools/wrap': patch +--- + +Only warn about deprecated `introspectSchema` once diff --git a/packages/wrap/src/introspect.ts b/packages/wrap/src/introspect.ts index a6930792aa4..33bb84b9b51 100644 --- a/packages/wrap/src/introspect.ts +++ b/packages/wrap/src/introspect.ts @@ -46,10 +46,15 @@ export type SchemaFromExecutorOptions = Partial & Parameters[1] & ParseOptions; +let hasWarned = false; + export const introspectSchema = function introspectSchema(...args) { - console.warn( - `\`introspectSchema\` is deprecated, and will be removed in the next major. Please use \`schemaFromExecutor\` instead.` - ); + if (!hasWarned) { + hasWarned = true; + console.warn( + `\`introspectSchema\` is deprecated, and will be removed in the next major. Please use \`schemaFromExecutor\` instead.` + ); + } return schemaFromExecutor(...(args as Parameters)); } as typeof schemaFromExecutor;