@@ -340,7 +292,10 @@
{#if !$flags.queryTransformerBanner}
+ window.open(
+ "https://docs.budibase.com/building-apps/data/transformers"
+ )}
on:change={() =>
flags.updateFlag("queryTransformerBanner", true)}
>
@@ -449,9 +404,9 @@
name="Variable"
headings
keyHeading="Name"
- keyPlaceholder="e.g. cookie"
+ keyPlaceholder="Variable name"
valueHeading={`Value`}
- valuePlaceholder={`e.g. {{ headers.set-cookie }}`}
+ valuePlaceholder={`{{ value }}`}
readOnly={variablesReadOnly}
/>
diff --git a/packages/client/manifest.json b/packages/client/manifest.json
index de2ebc51e0..b794df814f 100644
--- a/packages/client/manifest.json
+++ b/packages/client/manifest.json
@@ -2457,6 +2457,10 @@
"label": "Rows",
"key": "rows"
},
+ {
+ "label": "Extra Info",
+ "key": "info"
+ },
{
"label": "Rows Length",
"key": "rowsLength"
@@ -3178,6 +3182,10 @@
"label": "Rows",
"key": "rows"
},
+ {
+ "label": "Extra Info",
+ "key": "info"
+ },
{
"label": "Rows Length",
"key": "rowsLength"
diff --git a/packages/client/src/api/datasources.js b/packages/client/src/api/datasources.js
index 981d8301ca..a1d6b8dfd8 100644
--- a/packages/client/src/api/datasources.js
+++ b/packages/client/src/api/datasources.js
@@ -15,7 +15,8 @@ export const fetchDatasource = async dataSource => {
// Fetch all rows in data source
const { type, tableId, fieldName } = dataSource
- let rows = []
+ let rows = [],
+ info = {}
if (type === "table") {
rows = await fetchTableData(tableId)
} else if (type === "view") {
@@ -28,7 +29,12 @@ export const fetchDatasource = async dataSource => {
parameters[param.name] = param.default
}
}
- rows = await executeQuery({ queryId: dataSource._id, parameters })
+ const { data, ...rest } = await executeQuery({
+ queryId: dataSource._id,
+ parameters,
+ })
+ info = rest
+ rows = data
} else if (type === FieldTypes.LINK) {
rows = await fetchRelationshipData({
rowId: dataSource.rowId,
@@ -38,7 +44,7 @@ export const fetchDatasource = async dataSource => {
}
// Enrich the result is always an array
- return Array.isArray(rows) ? rows : []
+ return { rows: Array.isArray(rows) ? rows : [], info }
}
/**
diff --git a/packages/client/src/components/app/DataProvider.svelte b/packages/client/src/components/app/DataProvider.svelte
index e9d306cc3b..9c79ef8e9a 100644
--- a/packages/client/src/components/app/DataProvider.svelte
+++ b/packages/client/src/components/app/DataProvider.svelte
@@ -30,6 +30,7 @@
// Provider state
let rows = []
let allRows = []
+ let info = {}
let schema = {}
let bookmarks = [null]
let pageNumber = 0
@@ -120,6 +121,7 @@
// Build our data context
$: dataContext = {
rows,
+ info,
schema,
rowsLength: rows.length,
@@ -206,7 +208,9 @@
} else {
// For other data sources like queries or views, fetch all rows from the
// server
- allRows = await API.fetchDatasource(dataSource)
+ const data = await API.fetchDatasource(dataSource)
+ allRows = data.rows
+ info = data.info
}
loading = false
loaded = true
diff --git a/packages/server/src/api/controllers/query/index.js b/packages/server/src/api/controllers/query/index.js
index e12b0039a5..ff9d814bc9 100644
--- a/packages/server/src/api/controllers/query/index.js
+++ b/packages/server/src/api/controllers/query/index.js
@@ -182,13 +182,13 @@ exports.execute = async function (ctx) {
// call the relevant CRUD method on the integration class
try {
- const { rows } = await Runner.run({
+ const { rows, extra } = await Runner.run({
datasource,
queryVerb: query.queryVerb,
query: enrichedQuery,
transformer: query.transformer,
})
- ctx.body = rows
+ ctx.body = { data: rows, ...extra }
} catch (err) {
ctx.throw(400, err)
}
diff --git a/packages/server/src/automations/steps/executeQuery.js b/packages/server/src/automations/steps/executeQuery.js
index 43534209cc..0fa8661561 100644
--- a/packages/server/src/automations/steps/executeQuery.js
+++ b/packages/server/src/automations/steps/executeQuery.js
@@ -35,6 +35,11 @@ exports.definition = {
type: "object",
description: "The response from the datasource execution",
},
+ info: {
+ type: "object",
+ description:
+ "Some query types may return extra data, like headers from a REST query",
+ },
success: {
type: "boolean",
description: "Whether the action was successful",
@@ -68,13 +73,16 @@ exports.run = async function ({ inputs, appId, emitter }) {
try {
await queryController.execute(ctx)
+ const { data, ...rest } = ctx.body
return {
- response: ctx.body,
+ response: data,
+ info: rest,
success: true,
}
} catch (err) {
return {
success: false,
+ info: {},
response: automationUtils.getError(err),
}
}