|
|
|
@ -119,9 +119,8 @@ exports.preview = async function (ctx) { |
|
|
|
|
|
|
|
const enrichedQuery = await enrichQueryFields(fields, parameters) |
|
|
|
|
|
|
|
const rows = formatResponse( |
|
|
|
await new Integration(datasource.config)[queryVerb](enrichedQuery) |
|
|
|
) |
|
|
|
const integration = new Integration(datasource.config) |
|
|
|
const rows = formatResponse(await integration[queryVerb](enrichedQuery)) |
|
|
|
|
|
|
|
// get all the potential fields in the schema
|
|
|
|
const keys = rows.flatMap(Object.keys) |
|
|
|
@ -130,6 +129,10 @@ exports.preview = async function (ctx) { |
|
|
|
rows, |
|
|
|
schemaFields: [...new Set(keys)], |
|
|
|
} |
|
|
|
// cleanup
|
|
|
|
if (integration.end) { |
|
|
|
integration.end() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
exports.execute = async function (ctx) { |
|
|
|
@ -149,10 +152,13 @@ exports.execute = async function (ctx) { |
|
|
|
ctx.request.body.parameters |
|
|
|
) |
|
|
|
|
|
|
|
const integration = new Integration(datasource.config) |
|
|
|
// call the relevant CRUD method on the integration class
|
|
|
|
ctx.body = formatResponse( |
|
|
|
await new Integration(datasource.config)[query.queryVerb](enrichedQuery) |
|
|
|
) |
|
|
|
ctx.body = formatResponse(await integration[query.queryVerb](enrichedQuery)) |
|
|
|
// cleanup
|
|
|
|
if (integration.end) { |
|
|
|
integration.end() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
exports.destroy = async function (ctx) { |
|
|
|
|