From 8b8cf54ad2de7226b293f96313e1691865500d97 Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Fri, 30 Jun 2023 12:25:06 +0100 Subject: [PATCH] fix(core): Apply maskTypename earlier in the chain (#3298) --- .changeset/curvy-coins-travel.md | 5 +++++ packages/core/src/client.ts | 16 ++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 .changeset/curvy-coins-travel.md diff --git a/.changeset/curvy-coins-travel.md b/.changeset/curvy-coins-travel.md new file mode 100644 index 0000000000..0d94754964 --- /dev/null +++ b/.changeset/curvy-coins-travel.md @@ -0,0 +1,5 @@ +--- +'@urql/core': patch +--- + +Re-order `maskTypename` to apply masking earlier in the chain. diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 39d71f1f3f..d7ebaa1d71 100755 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -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( @@ -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$); };