From 687bb54996fc387667e28eb3462a41467bddcf7c Mon Sep 17 00:00:00 2001 From: General Kroll Date: Wed, 11 Nov 2026 10:16:51 +1100 Subject: [PATCH] graphql-bugfix Summary: - Bugfix for `graphql` transform shortfall. - Added robot test `GraphQL Response Transform Applies Before Selection And Pagination`. --- go.mod | 2 +- go.sum | 4 +- .../v0.1.0/services/graphql.yaml | 60 +++++++++++++++++++ .../stackql_graphql_pagination.robot | 18 ++++++ 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 106f20c9..77e8fd8a 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/spf13/cobra v1.10.2 github.com/spf13/pflag v1.0.10 github.com/spf13/viper v1.10.1 - github.com/stackql-labs/omnisdk v0.1.10-alpha04 + github.com/stackql-labs/omnisdk v0.1.10-beta01 github.com/stackql/go-suffix-map v0.0.1-alpha02 github.com/stackql/psql-wire v0.1.2-beta02 github.com/stackql/stackql-parser v0.0.17-alpha05 diff --git a/go.sum b/go.sum index 40ee9bbe..1fbd578c 100644 --- a/go.sum +++ b/go.sum @@ -328,8 +328,8 @@ github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/spiffe/go-spiffe/v2 v2.7.0 h1:uXe1MflJoHw58wAUvxVlcM7WpKtijWG7I1UidcGh6g4= github.com/spiffe/go-spiffe/v2 v2.7.0/go.mod h1:47Q0Q9/AqGha8QLHp+kxpH4Wca7X7EnOtlIJy3mxZ3U= -github.com/stackql-labs/omnisdk v0.1.10-alpha04 h1:wADTbRDAsRnk23+iIFm2gL12ajqz7P9H7XYQ4VsegWg= -github.com/stackql-labs/omnisdk v0.1.10-alpha04/go.mod h1:pwxphb3OMfEui7uCMmReoB+ABshSBl83dszn4Sf4vcg= +github.com/stackql-labs/omnisdk v0.1.10-beta01 h1:jpIiIfcpC5hm0MnBNxBz8iHNaHTFmvt0Xlcpw61RqMI= +github.com/stackql-labs/omnisdk v0.1.10-beta01/go.mod h1:pwxphb3OMfEui7uCMmReoB+ABshSBl83dszn4Sf4vcg= github.com/stackql/go-suffix-map v0.0.1-alpha02 h1:JI4aiq/OfHW4a/BiNqK31NbyaR94zlUOhGZof3G/OUo= github.com/stackql/go-suffix-map v0.0.1-alpha02/go.mod h1:6BSMz4K/gIYfqdVRb7V8xL165wiPYyCjD9Kx7hLMd9Y= github.com/stackql/psql-wire v0.1.2-beta02 h1:7DfliBpyyCaUHVJ1Jxk37q3zVwVLyh6+FCHeM0/gbAQ= diff --git a/test/registry/src/stackql_native_test/v0.1.0/services/graphql.yaml b/test/registry/src/stackql_native_test/v0.1.0/services/graphql.yaml index 6258dda4..a68fb14a 100644 --- a/test/registry/src/stackql_native_test/v0.1.0/services/graphql.yaml +++ b/test/registry/src/stackql_native_test/v0.1.0/services/graphql.yaml @@ -11,6 +11,38 @@ info: servers: - url: http://localhost:1070 paths: + /graphql/transformed: + post: + x-stackql-protocol: graphql + x-stackQL-graphQL: + # Reuse the raw Relay mock; these paths exist only after the transform. + url: http://localhost:1070/graphql/pageinfo + httpVerb: POST + responseSelection: + jsonPath: '$.result[*]' + cursor: + strategy: page_info + jsonPath: '$.pagination.endCursor' + terminateOnJsonPath: '$.pagination.hasNextPage' + query: > + query { + pthings(first: {{ .limit }}{{ .cursor }}) { + edges { node { name rank } cursor } + pageInfo { hasNextPage endCursor } + } + } + responses: + '200': + description: Transformed response + content: + application/json: + schema: + type: object + properties: + result: + type: array + items: + $ref: '#/components/schemas/strategy_thing' /graphql: post: x-stackQL-graphQL: @@ -219,6 +251,34 @@ components: wire_after: type: string x-stackQL-resources: + transformed_things: + id: stackql_native_test.graph.transformed_things + name: transformed_things + title: Things (GraphQL response transform) + methods: + list: + x-stackql-protocol: graphql + operation: + $ref: '#/paths/~1graphql~1transformed/post' + response: + mediaType: application/json + openAPIDocKey: '200' + objectKey: '$.result' + transform: + type: golang_template_json_v0.3.0 + body: | + { + "result": [ + {{- range $i, $edge := (index . "data" "pthings" "edges") }} + {{- if $i }},{{ end }} + {{ toJson (index $edge "node") }} + {{- end }} + ], + "pagination": {{ toJson (index . "data" "pthings" "pageInfo") }} + } + sqlVerbs: + select: + - $ref: '#/components/x-stackQL-resources/transformed_things/methods/list' things: id: stackql_native_test.graph.things name: things diff --git a/test/robot/functional/stackql_graphql_pagination.robot b/test/robot/functional/stackql_graphql_pagination.robot index c8cea015..e18488fa 100644 --- a/test/robot/functional/stackql_graphql_pagination.robot +++ b/test/robot/functional/stackql_graphql_pagination.robot @@ -7,6 +7,24 @@ Documentation GraphQL acquire path against the no-auth stackql_native_test m ... wire_after) so wire shape is asserted from STDOUT. *** Test Cases *** +GraphQL Response Transform Applies Before Selection And Pagination + [Documentation] Regression for https://github.com/stackql-labs/omnisdk/issues/37. + ... Selection, cursor and termination paths exist only in the transformed reply. + ... Assert every row and the cursors sent on pages two and three; the final + ... non-empty cursor must terminate via the transformed hasNextPage flag. + [Timeout] 60 seconds + Should StackQL Exec Inline Equal + ... ${STACKQL_EXE} + ... ${OKTA_SECRET_STR} + ... ${GITHUB_SECRET_STR} + ... ${K8S_SECRET_STR} + ... ${REGISTRY_NO_VERIFY_CFG_STR} + ... ${AUTH_CFG_STR} + ... ${SQL_BACKEND_CFG_STR_CANONICAL} + ... select name, rank, wire_after from stackql_native_test.graph.transformed_things order by rank limit 100; + ... name,rank,wire_after\nred,1,\ngreen,2,\nblue,3,c1\nyellow,4,c1\npurple,5,c3 + ... stackql_output=csv + GraphQL Cursor Pagination Returns All Pages [Documentation] The mock serves two things per page; the reader follows endCursor until exhausted. Should StackQL Exec Inline Contain