From f7a7b99f3d67cc6c8d7f8f21902325af71d97e48 Mon Sep 17 00:00:00 2001 From: Daniel Chambers Date: Thu, 18 Jan 2024 18:05:54 +1100 Subject: [PATCH] Fixed queries with variables returning incorrect result format (#90) * Fix queries with variables returning incorrect result format * Update changelog --- CHANGELOG.md | 4 ++++ src/connector.ts | 14 ++++++++------ src/sdk.ts | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9e99c3..db418cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ This changelog documents the changes between release versions. Changes to be included in the next upcoming release. +Update TS SDK dependency to v1.2.8. + +* Fixed issue where query response format was incorrect when variables were used in the request + ## v0.22 Update TS SDK Dependency to v1.2.6. diff --git a/src/connector.ts b/src/connector.ts index 1120086..83ee9eb 100644 --- a/src/connector.ts +++ b/src/connector.ts @@ -357,17 +357,19 @@ export const connector: sdk.Connector = request: sdk.QueryRequest ): Promise { - const rows = []; + const rowSets: sdk.RowSet[] = []; for(const variables of request.variables ?? [{}]) { const args = resolveArguments(request.collection, request.arguments, variables); const result = await query(configuration, state, request.collection, args, request.query.fields ?? null); - rows.push({ '__value': result }); + rowSets.push({ + aggregates: {}, + rows: [ + { '__value': result } + ] + }); } - return [{ - aggregates: {}, - rows - }]; + return rowSets; }, async mutation( diff --git a/src/sdk.ts b/src/sdk.ts index 4cd522e..2a1d331 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -1,4 +1,4 @@ // Have this dependency defined in one place -export * as sdk from 'npm:@hasura/ndc-sdk-typescript@1.2.6'; \ No newline at end of file +export * as sdk from 'npm:@hasura/ndc-sdk-typescript@1.2.8';