Merge pull request #15336 from Budibase/cleanup/only-fetch-data-when-required

Explicitly fetch the data from fetch
This commit is contained in:
Adria Navarro 2025-01-10 11:05:37 +01:00 committed by GitHub
commit 2159b9f93e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 6 deletions

View File

@ -31,7 +31,7 @@ const getDatasourceFetchInstance = datasource => {
if (!handler) { if (!handler) {
return null return null
} }
return new handler({ API }) return new handler({ API, datasource })
} }
/** /**
@ -52,7 +52,7 @@ export const fetchDatasourceSchema = async (
// Get the normal schema as long as we aren't wanting a form schema // Get the normal schema as long as we aren't wanting a form schema
let schema let schema
if (datasource?.type !== "query" || !options?.formSchema) { if (datasource?.type !== "query" || !options?.formSchema) {
schema = instance.getSchema(datasource, definition) schema = instance.getSchema(definition)
} else if (definition.parameters?.length) { } else if (definition.parameters?.length) {
schema = {} schema = {}
definition.parameters.forEach(param => { definition.parameters.forEach(param => {

View File

@ -179,9 +179,6 @@ export default abstract class DataFetch<
this.store.update($store => ({ ...$store, loaded: true })) this.store.update($store => ({ ...$store, loaded: true }))
return return
} }
// Initially fetch data but don't bother waiting for the result
this.getInitialData()
} }
/** /**

View File

@ -33,7 +33,12 @@ const DataFetchMap = {
export const fetchData = ({ API, datasource, options }: any) => { export const fetchData = ({ API, datasource, options }: any) => {
const Fetch = const Fetch =
DataFetchMap[datasource?.type as keyof typeof DataFetchMap] || TableFetch 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 // Creates an empty fetch instance with no datasource configured, so no data