Skip to content

Commit

Permalink
fix(utils): pass the value as-is if it cannot be parsed by the actual…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
ardatan committed Mar 22, 2022
1 parent 4a099b2 commit d36d530
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .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
16 changes: 14 additions & 2 deletions packages/utils/src/transformInputValue.ts
Expand Up @@ -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) {
Expand Down

1 comment on commit d36d530

@vercel
Copy link

@vercel vercel bot commented on d36d530 Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.