Skip to content

Commit

Permalink
Use Object.assign for addTypenameToDocument.added.
Browse files Browse the repository at this point in the history
Another opportunity to apply @brainkim's suggestion from this comment:
#8222 (comment)
  • Loading branch information
benjamn committed Jun 15, 2021
1 parent 51f2e11 commit b9719a6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/utilities/graphql/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ export function removeDirectivesFromDocument(
return modifiedDoc;
}

export function addTypenameToDocument(doc: DocumentNode): DocumentNode {
export const addTypenameToDocument = Object.assign(function (
doc: DocumentNode
): DocumentNode {
return visit(checkDocument(doc), {
SelectionSet: {
enter(node, _key, parent) {
Expand Down Expand Up @@ -259,14 +261,11 @@ export function addTypenameToDocument(doc: DocumentNode): DocumentNode {
},
},
});
}

export interface addTypenameToDocument {
added(field: FieldNode): boolean;
}
addTypenameToDocument.added = function (field: FieldNode) {
return field === TYPENAME_FIELD;
};
}, {
added(field: FieldNode): boolean {
return field === TYPENAME_FIELD;
},
});

const connectionRemoveConfig = {
test: (directive: DirectiveNode) => {
Expand Down

0 comments on commit b9719a6

Please sign in to comment.