Skip to content

Commit

Permalink
fix: same fix for network-only
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-min committed Jun 1, 2024
1 parent f26a8f5 commit e0e52c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ 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 = input.requestPolicy === "network-only" ? 2 : 1;
let skipQueries = 2;
const onRender = () => {
this.shouldQuery = false;
if (!--skipQueries) {
this.removeListener("render", onRender);
this.doQuery({ requestPolicy: "cache-first" });
}
};
this.on("render", onRender);
Expand Down Expand Up @@ -86,16 +87,20 @@ class {
}
this.unsubscribe = pipe(
getClient(undefined, this.input.name).query(this.input.query, this.input.variables, {
requestPolicy: this.input.requestPolicy,
...options,
}),
getClient(undefined, this.input.name).query(
this.input.query,
this.input.variables,
{
requestPolicy: this.input.requestPolicy,
...options,
},
),
subscribe(({ data, error, stale }) => {
this.stopTimeout();
this.state.data = data;
this.state.error = error;
this.state.fetching = !!stale;
})
}),
).unsubscribe;
}
}
Expand All @@ -105,7 +110,7 @@ class {
state,
(options) => {
component.doQuery({ requestPolicy: "network-only", ...options });
}
},
)/>
</if>
<else>
Expand Down
1 change: 0 additions & 1 deletion src/node_modules/@internal/gql-query/node.marko
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static function errorToJSON() {
<gql-query-client
key="gqlc"
name=input.name
requestPolicy=input.requestPolicy
data=data
error=error
opKey=operation.key
Expand Down

0 comments on commit e0e52c2

Please sign in to comment.