From e68cb8bcaf9baddf6fca747abab871ecd1bc7a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Bour=C3=A9?= Date: Sun, 22 Jan 2023 03:21:22 +0100 Subject: [PATCH] fix: VariableJSONSchema for custom scalars (#2986) --- .changeset/eight-crews-clean.md | 5 +++++ .../src/utils/getVariablesJSONSchema.ts | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 .changeset/eight-crews-clean.md diff --git a/.changeset/eight-crews-clean.md b/.changeset/eight-crews-clean.md new file mode 100644 index 00000000000..094803988e7 --- /dev/null +++ b/.changeset/eight-crews-clean.md @@ -0,0 +1,5 @@ +--- +'graphql-language-service': patch +--- + +Fix JSON schema for custom scalars validation diff --git a/packages/graphql-language-service/src/utils/getVariablesJSONSchema.ts b/packages/graphql-language-service/src/utils/getVariablesJSONSchema.ts index 63fe1a2324c..0b6833e599f 100644 --- a/packages/graphql-language-service/src/utils/getVariablesJSONSchema.ts +++ b/packages/graphql-language-service/src/utils/getVariablesJSONSchema.ts @@ -144,9 +144,8 @@ function getJSONSchemaFromGraphQLType( definition.enum = type.getValues().map(val => val.name); } - if (isScalarType(type)) { - // I think this makes sense for custom scalars? - definition.type = scalarTypesMap[type.name] ?? 'any'; + if (isScalarType(type) && scalarTypesMap[type.name]) { + definition.type = scalarTypesMap[type.name]; } if (isListType(type)) { definition.type = 'array';