From d36d530baa8451b3c4b84a8e002404a42d8aff62 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Tue, 22 Mar 2022 18:20:27 +0300 Subject: [PATCH] fix(utils): pass the value as-is if it cannot be parsed by the actual type --- .changeset/yellow-tools-cough.md | 5 +++++ packages/utils/src/transformInputValue.ts | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 .changeset/yellow-tools-cough.md diff --git a/.changeset/yellow-tools-cough.md b/.changeset/yellow-tools-cough.md new file mode 100644 index 00000000000..acc9ba6af8e --- /dev/null +++ b/.changeset/yellow-tools-cough.md @@ -0,0 +1,5 @@ +--- +'@graphql-tools/utils': patch +--- + +fix(utils): pass the value as-is if it cannot be parsed by the actual type diff --git a/packages/utils/src/transformInputValue.ts b/packages/utils/src/transformInputValue.ts index 530a0a7be19..fd40b90b747 100644 --- a/packages/utils/src/transformInputValue.ts +++ b/packages/utils/src/transformInputValue.ts @@ -41,11 +41,23 @@ export function transformInputValue( } export function serializeInputValue(type: GraphQLInputType, value: any) { - return transformInputValue(type, value, (t, v) => t.serialize(v)); + return transformInputValue(type, value, (t, v) => { + try { + return t.serialize(v); + } catch { + return v; + } + }); } export function parseInputValue(type: GraphQLInputType, value: any) { - return transformInputValue(type, value, (t, v) => t.parseValue(v)); + return transformInputValue(type, value, (t, v) => { + try { + return t.parseValue(v); + } catch { + return v; + } + }); } export function parseInputValueLiteral(type: GraphQLInputType, value: any) {