From a5ec51028099325a288ab9fc4bca5e1978d634cb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 9 Jan 2025 15:58:59 +0100 Subject: [PATCH 1/3] Explicitly fetch the data from fetch --- packages/frontend-core/src/fetch/DataFetch.ts | 3 --- packages/frontend-core/src/fetch/index.ts | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/frontend-core/src/fetch/DataFetch.ts b/packages/frontend-core/src/fetch/DataFetch.ts index 9312c57637..0079fec057 100644 --- a/packages/frontend-core/src/fetch/DataFetch.ts +++ b/packages/frontend-core/src/fetch/DataFetch.ts @@ -179,9 +179,6 @@ export default abstract class DataFetch< this.store.update($store => ({ ...$store, loaded: true })) return } - - // Initially fetch data but don't bother waiting for the result - this.getInitialData() } /** diff --git a/packages/frontend-core/src/fetch/index.ts b/packages/frontend-core/src/fetch/index.ts index 4accb0b5ec..c1f35abef2 100644 --- a/packages/frontend-core/src/fetch/index.ts +++ b/packages/frontend-core/src/fetch/index.ts @@ -33,7 +33,12 @@ const DataFetchMap = { export const fetchData = ({ API, datasource, options }: any) => { const Fetch = DataFetchMap[datasource?.type as keyof typeof DataFetchMap] || TableFetch - return new Fetch({ API, datasource, ...options }) + const fetch = new Fetch({ API, datasource, ...options }) + + // Initially fetch data but don't bother waiting for the result + fetch.getInitialData() + + return fetch } // Creates an empty fetch instance with no datasource configured, so no data From 40192097d819564573343d47cd85a63b00d8be39 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 9 Jan 2025 14:32:15 +0100 Subject: [PATCH 2/3] Pass datasource to instance --- packages/client/src/utils/schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/utils/schema.js b/packages/client/src/utils/schema.js index ffab142cf3..988c2e3316 100644 --- a/packages/client/src/utils/schema.js +++ b/packages/client/src/utils/schema.js @@ -31,7 +31,7 @@ const getDatasourceFetchInstance = datasource => { if (!handler) { return null } - return new handler({ API }) + return new handler({ API, datasource }) } /** From cbad9303d962f3b118186099aaf5c50f092b9668 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 9 Jan 2025 14:24:59 +0100 Subject: [PATCH 3/3] Fix getSchema from forms --- packages/client/src/utils/schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/src/utils/schema.js b/packages/client/src/utils/schema.js index 988c2e3316..60800afc53 100644 --- a/packages/client/src/utils/schema.js +++ b/packages/client/src/utils/schema.js @@ -52,7 +52,7 @@ export const fetchDatasourceSchema = async ( // Get the normal schema as long as we aren't wanting a form schema let schema if (datasource?.type !== "query" || !options?.formSchema) { - schema = instance.getSchema(datasource, definition) + schema = instance.getSchema(definition) } else if (definition.parameters?.length) { schema = {} definition.parameters.forEach(param => {