Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit f81b055

Browse files
committed
Take possession of node and selection objects within a FragmentSpec
Otherwise, it turns out the `.splice()` calls modify the query directly, which can contaminate other specs in really weird ways 😱
1 parent ef2f625 commit f81b055

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/builder/graphql/base/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export class FragmentSpec extends Spec {
5252
);
5353
throw new Error(`Unrecognized node kind ${node.kind}`);
5454
} else {
55-
return fn(node);
55+
return fn({...node});
5656
}
5757
});
5858

@@ -62,7 +62,6 @@ export class FragmentSpec extends Spec {
6262
for (let i = selections.length - 1; i >= 0; i--) {
6363
if (selections[i].kind === 'InlineFragment') {
6464
// Replace inline fragments in-place with their selected fields *if* the GraphQL type name matches.
65-
6665
if (!typeNameSet.has(selections[i].type)) {
6766
continue;
6867
}
@@ -77,6 +76,7 @@ export class FragmentSpec extends Spec {
7776
};
7877

7978
for (const node of this.nodes) {
79+
node.selections = node.selections.slice();
8080
flattenFragments(node.selections);
8181
}
8282
}

0 commit comments

Comments
 (0)