Skip to content

Commit

Permalink
fix(core): Apply maskTypename earlier in the chain (#3298)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored Jun 30, 2023
1 parent 19d2674 commit 8b8cf54
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-coins-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@urql/core': patch
---

Re-order `maskTypename` to apply masking earlier in the chain.
16 changes: 8 additions & 8 deletions packages/core/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,14 @@ export const Client: new (opts: ClientOptions) => Client = function Client(
)
);

// Mask typename properties if the option for it is turned on
if (opts.maskTypename) {
result$ = pipe(
result$,
map(res => ({ ...res, data: maskTypename(res.data, true) }))
);
}

if (operation.kind !== 'query') {
// Interrupt subscriptions and mutations when they have no more results
result$ = pipe(
Expand Down Expand Up @@ -705,14 +713,6 @@ export const Client: new (opts: ClientOptions) => Client = function Client(
);
}

// Mask typename properties if the option for it is turned on
if (opts.maskTypename) {
result$ = pipe(
result$,
map(res => ({ ...res, data: maskTypename(res.data, true) }))
);
}

return share(result$);
};

Expand Down

0 comments on commit 8b8cf54

Please sign in to comment.