Skip to content

Commit

Permalink
add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Nov 19, 2024
1 parent a40589a commit 9ccb9ee
Showing 1 changed file with 101 additions and 0 deletions.
101 changes: 101 additions & 0 deletions src/core/__tests__/masking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,107 @@ describe("maskOperation", () => {
});
});

test("masks fragments from nested objects when query gets fields from same object", () => {
const query = gql`
query {
user {
...FragmentA @unmask
...FragmentB
...FragmentC @unmask
}
}
fragment FragmentA on User {
this {
is {
very {
deeply {
nested {
a
}
}
}
}
}
}
fragment FragmentB on User {
this {
is {
very {
deeply {
nested {
b
}
}
}
}
}
}
fragment FragmentC on User {
this {
is {
very {
deeply {
nested {
c
}
}
}
}
}
}
`;

const data = maskOperation(
deepFreeze({
user: {
__typename: "User",
this: {
is: [
{
very: {
deeply: [
{
nested: {
a: 1,
b: 2,
c: 3,
},
},
],
},
},
],
},
},
}),
query,
new InMemoryCache()
);

expect(data).toEqual({
user: {
__typename: "User",
this: {
is: [
{
very: {
deeply: [
{
nested: {
a: 1,
c: 3,
},
},
],
},
},
],
},
},
});
});

test("handles nulls in child selection sets", () => {
const query = gql`
query {
Expand Down

0 comments on commit 9ccb9ee

Please sign in to comment.