Skip to content

Commit

Permalink
fix: fix removeTypenameFromInputs with apollo v3
Browse files Browse the repository at this point in the history
  • Loading branch information
eturino committed Aug 20, 2020
1 parent 60fd4bf commit 9540d13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"lodash.isstring": "^4.0.1",
"lodash.isundefined": "^3.0.1",
"lodash.mapvalues": "^4.6.0",
"lodash.omit": "^4.5.0",
"lodash.pickby": "^4.6.0",
"lodash.reduce": "^4.6.0",
"lodash.uniqby": "^4.7.0",
Expand All @@ -88,6 +89,7 @@
"@types/lodash.isstring": "^4.0.6",
"@types/lodash.isundefined": "^3.0.6",
"@types/lodash.mapvalues": "^4.6.6",
"@types/lodash.omit": "^4.5.6",
"@types/lodash.pickby": "^4.6.6",
"@types/lodash.reduce": "^4.6.6",
"@types/lodash.uniqby": "^4.7.6",
Expand Down
8 changes: 4 additions & 4 deletions src/lib/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "graphql";
import has from "lodash.has";
import mapValues from "lodash.mapvalues";
import omit from "lodash.omit";
import { FunctionsMap, isNone, mapIfArray } from "..";

export class Serializer {
Expand Down Expand Up @@ -43,10 +44,9 @@ export class Serializer {
return fns.serialize(value);
}

protected serializeInputObject(value: any, type: GraphQLInputObjectType): any {
if (this.removeTypenameFromInputs && has(value, "__typename")) {
delete value.__typename;
}
protected serializeInputObject(givenValue: any, type: GraphQLInputObjectType): any {
const value =
this.removeTypenameFromInputs && has(givenValue, "__typename") ? omit(givenValue, "__typename") : givenValue;

const fields = type.getFields();
return mapValues(value, (v, key) => {
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,13 @@
dependencies:
"@types/lodash" "*"

"@types/lodash.omit@^4.5.6":
version "4.5.6"
resolved "https://registry.yarnpkg.com/@types/lodash.omit/-/lodash.omit-4.5.6.tgz#f2a9518259e481a48ff7ec423420fa8fd58933e2"
integrity sha512-KXPpOSNX2h0DAG2w7ajpk7TXvWF28ZHs5nJhOJyP0BQHkehgr948RVsToItMme6oi0XJkp19CbuNXkIX8FiBlQ==
dependencies:
"@types/lodash" "*"

"@types/lodash.pickby@^4.6.6":
version "4.6.6"
resolved "https://registry.yarnpkg.com/@types/lodash.pickby/-/lodash.pickby-4.6.6.tgz#3dc39c2b38432f7a0c5e5627b0d5c0e3878b4f35"
Expand Down Expand Up @@ -4208,6 +4215,11 @@ lodash.memoize@4.x:
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=

lodash.omit@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60"
integrity sha1-brGa5aHuHdnfC5aeZs4Lf6MLXmA=

lodash.pickby@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff"
Expand Down

0 comments on commit 9540d13

Please sign in to comment.