Skip to content

Commit

Permalink
Merge pull request #15336 from Budibase/cleanup/only-fetch-data-when-…
Browse files Browse the repository at this point in the history
…required

Explicitly fetch the data from fetch
  • Loading branch information
adrinr authored Jan 10, 2025
2 parents a0f5cb6 + cbad930 commit 2159b9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/client/src/utils/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const getDatasourceFetchInstance = datasource => {
if (!handler) {
return null
}
return new handler({ API })
return new handler({ API, datasource })
}

/**
Expand All @@ -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 => {
Expand Down
3 changes: 0 additions & 3 deletions packages/frontend-core/src/fetch/DataFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

/**
Expand Down
7 changes: 6 additions & 1 deletion packages/frontend-core/src/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2159b9f

Please sign in to comment.