From 12cb169ab3f41a0d2eac017480d327e4eb6a7d48 Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Wed, 27 Nov 2024 11:23:13 -0700 Subject: [PATCH] fix: issue with sync hydrate from parent (#27) --- .../@internal/gql-query/browser.marko | 6 +++++- .../components/gql-query-client/index.marko | 15 ++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/node_modules/@internal/gql-query/browser.marko b/src/node_modules/@internal/gql-query/browser.marko index a2e90ae..f234e5c 100644 --- a/src/node_modules/@internal/gql-query/browser.marko +++ b/src/node_modules/@internal/gql-query/browser.marko @@ -1,5 +1,10 @@ import { readyLookup } from "@internal/client"; +$ const id = component.elId("@gqlc"); +$ if (!component.ready && readyLookup[id]) { + component.ready = true; + readyLookup[id](); +}
$ component.ready = true;
$ if (!component.ready) { - const id = component.elId("@gqlc"); readyLookup[id] = () => { delete readyLookup[id]; component.ready = true; 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 05791fe..ada90b4 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 @@ -19,18 +19,15 @@ class { } } else if (input.opKey) { this.setInput(input); - const hydrate = (ready) => { - hydrateQuery(input.opKey, data, error, input.name); - ready(); - } if (readyLookup[this.id]) { - hydrate(readyLookup[this.id]); + hydrateQuery(input.opKey, data, error, input.name); + readyLookup[this.id](); } else { - Object.defineProperty(readyLookup, this.id, { - configurable: true, - set: hydrate - }); + readyLookup[this.id] = () => { + delete readyLookup[this.id]; + hydrateQuery(input.opKey, data, error, input.name); + } } } }