Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
60 changes: 60 additions & 0 deletions test/registry/src/stackql_native_test/v0.1.0/services/graphql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions test/robot/functional/stackql_graphql_pagination.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading