From f26a8f5e3c9e4264671584ffec85cb7016fab774 Mon Sep 17 00:00:00 2001 From: Bill Min Date: Sat, 1 Jun 2024 10:50:57 -0400 Subject: [PATCH] fix: only skip all initial render when network-only --- .../gql-query/components/gql-query-client/index.marko | 6 +++--- src/node_modules/@internal/gql-query/node.marko | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/node_modules/@internal/gql-query/components/gql-query-client/index.marko b/src/node_modules/@internal/gql-query/components/gql-query-client/index.marko index dda900a..aa71693 100644 --- a/src/node_modules/@internal/gql-query/components/gql-query-client/index.marko +++ b/src/node_modules/@internal/gql-query/components/gql-query-client/index.marko @@ -16,7 +16,7 @@ class { const ready = readyLookup[this.id]; if (ready) { // Hydration takes a double render pass, we avoid doing a new query until that's done. - let skipQueries = 2; + let skipQueries = input.requestPolicy === "network-only" ? 2 : 1; const onRender = () => { this.shouldQuery = false; if (!--skipQueries) { @@ -90,11 +90,11 @@ class { requestPolicy: this.input.requestPolicy, ...options, }), - subscribe(({ data, error }) => { + subscribe(({ data, error, stale }) => { this.stopTimeout(); this.state.data = data; this.state.error = error; - this.state.fetching = false; + this.state.fetching = !!stale; }) ).unsubscribe; } diff --git a/src/node_modules/@internal/gql-query/node.marko b/src/node_modules/@internal/gql-query/node.marko index e6cc330..356eebb 100644 --- a/src/node_modules/@internal/gql-query/node.marko +++ b/src/node_modules/@internal/gql-query/node.marko @@ -19,6 +19,7 @@ static function errorToJSON() {