Skip to content

Commit

Permalink
Merge branch 'main' into nithin/eng-5035-custom-scripts-in-the-playgr…
Browse files Browse the repository at this point in the history
…ound
  • Loading branch information
thisisnithin authored Oct 30, 2024
2 parents 9494860 + 82b9c28 commit 8af0dca
Show file tree
Hide file tree
Showing 30 changed files with 322 additions and 115 deletions.
6 changes: 6 additions & 0 deletions aws-lambda-router/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Binaries are attached to the github release otherwise all images can be found [h
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.36.0](https://github.com/wundergraph/cosmo/compare/[email protected]@0.36.0) (2024-10-29)

### Features

* extend apollo compatible error support ([#1311](https://github.com/wundergraph/cosmo/issues/1311)) ([d4d727e](https://github.com/wundergraph/cosmo/commit/d4d727e1c98f92eaa2103ca2356537e3a63eeff2)) (@Aenimus)

# [0.35.0](https://github.com/wundergraph/cosmo/compare/[email protected]@0.35.0) (2024-10-28)

### Features
Expand Down
4 changes: 2 additions & 2 deletions aws-lambda-router/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ require (
github.com/akrylysov/algnhsa v1.1.0
github.com/aws/aws-lambda-go v1.43.0
github.com/stretchr/testify v1.9.0
github.com/wundergraph/cosmo/router v0.0.0-20241027092036-e74bdb968e8a
github.com/wundergraph/cosmo/router v0.0.0-20241028212443-646650d431c5
go.uber.org/zap v1.27.0
)

Expand Down Expand Up @@ -93,7 +93,7 @@ require (
github.com/twmb/franz-go v1.16.1 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.7.0 // indirect
github.com/wundergraph/astjson v0.0.0-20240910140849-bb15f94bd362 // indirect
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.113 // indirect
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.23.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions aws-lambda-router/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,10 @@ github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/wundergraph/astjson v0.0.0-20240910140849-bb15f94bd362 h1:MxNSJqQFJyhKwU4xPj6diIRLm+oY1wNbAZW0jJpikBE=
github.com/wundergraph/astjson v0.0.0-20240910140849-bb15f94bd362/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/cosmo/router v0.0.0-20241027092036-e74bdb968e8a h1:Y8eZOHfqLU4nbkzlGEfic54wL0zjwO8ZmSy59omADC0=
github.com/wundergraph/cosmo/router v0.0.0-20241027092036-e74bdb968e8a/go.mod h1:BpOyKj34vLTYK694X2qjQLuc6LcHKKzMIl/9Qhytobg=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.113 h1:lo6ZgsLNJF4Qc+TCH4h0KPc48ew5GS6i1rB/iCjRfBg=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.113/go.mod h1:2FThDhi9IFpRv/l/L4BQJM2+Az8TYdq7tFycTPGOuFY=
github.com/wundergraph/cosmo/router v0.0.0-20241028212443-646650d431c5 h1:K10t90fNSqBpfYvboMMWaRLp2gELe2s3OcFXWoR4V3s=
github.com/wundergraph/cosmo/router v0.0.0-20241028212443-646650d431c5/go.mod h1:3wz3decKAtmKV763fUQcyLm705vq/hkvgQTeYPqBjkc=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115 h1:D45Z2XpuQjHtKEDSNX41r1aLkQGS2oB8I43vcDTSmEw=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115/go.mod h1:2FThDhi9IFpRv/l/L4BQJM2+Az8TYdq7tFycTPGOuFY=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24=
Expand Down
2 changes: 1 addition & 1 deletion aws-lambda-router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-lambda-router",
"version": "0.35.0",
"version": "0.36.0",
"private": true,
"description": "Placeholder package to simplify versioning and releasing with lerna.",
"keywords": [
Expand Down
4 changes: 2 additions & 2 deletions demo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ require (
github.com/rs/cors v1.11.0
github.com/vektah/gqlparser/v2 v2.5.16
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d
github.com/wundergraph/cosmo/router v0.0.0-20241027092036-e74bdb968e8a
github.com/wundergraph/cosmo/router v0.0.0-20241029112307-e101eaccac90
github.com/wundergraph/cosmo/router-tests v0.0.0-20241024215101-0c757faf23de
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.113
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1
go.opentelemetry.io/otel v1.28.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.23.1
Expand Down
6 changes: 3 additions & 3 deletions demo/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ github.com/wundergraph/astjson v0.0.0-20240910140849-bb15f94bd362 h1:MxNSJqQFJyh
github.com/wundergraph/astjson v0.0.0-20240910140849-bb15f94bd362/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d h1:NEUrhuqOaTO1dpW8pz2tu6dKbQAqFvgiF/m4NXdzZm0=
github.com/wundergraph/cosmo/composition-go v0.0.0-20240124120900-5effe48a4a1d/go.mod h1:9I3gPMAlAY+m1/cFL20iN7XHTyuZd3VT5ijccdU/FsI=
github.com/wundergraph/cosmo/router v0.0.0-20241027092036-e74bdb968e8a h1:Y8eZOHfqLU4nbkzlGEfic54wL0zjwO8ZmSy59omADC0=
github.com/wundergraph/cosmo/router v0.0.0-20241027092036-e74bdb968e8a/go.mod h1:BpOyKj34vLTYK694X2qjQLuc6LcHKKzMIl/9Qhytobg=
github.com/wundergraph/cosmo/router v0.0.0-20241029112307-e101eaccac90 h1:+P+uBq3nCrK11d1acHiFJ2UXGUAPsqFAzzT3TsiJdlI=
github.com/wundergraph/cosmo/router v0.0.0-20241029112307-e101eaccac90/go.mod h1:PeJdcguyQm4RZgdQp6WSEdvPD/+2tDmDkIAVlSXN4L4=
github.com/wundergraph/cosmo/router-tests v0.0.0-20241024215101-0c757faf23de h1:kEiNUGYSxHaT1I5GKre0GqHFCHVabpC/N33Chfue/rs=
github.com/wundergraph/cosmo/router-tests v0.0.0-20241024215101-0c757faf23de/go.mod h1:7WvZF+cOkfV4GaXka1qZfCqf/9GmOcksbPoMmJXtja4=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.113 h1:lo6ZgsLNJF4Qc+TCH4h0KPc48ew5GS6i1rB/iCjRfBg=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115 h1:D45Z2XpuQjHtKEDSNX41r1aLkQGS2oB8I43vcDTSmEw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
Expand Down
4 changes: 4 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ use (
./router-tests
)

// Two dirs up
// replace github.com/wundergraph/graphql-go-tools/v2 => ../../graphql-go-tools/v2

// One dir up
//replace github.com/wundergraph/graphql-go-tools/v2 => ../graphql-go-tools/v2

//replace github.com/wundergraph/astjson => ../astjson
2 changes: 2 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,8 @@ github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.90/go.mod h1:zkPVYJu1iQd0y1
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.95/go.mod h1:zkPVYJu1iQd0y1fBNj+oXe9uMI/33TSoiXEsKSAESZY=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.102 h1:UUT6mLcUH1sGepg+GFZr6TfC+mkZWF3YLdnQruBvIZA=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.102/go.mod h1:zkPVYJu1iQd0y1fBNj+oXe9uMI/33TSoiXEsKSAESZY=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115 h1:D45Z2XpuQjHtKEDSNX41r1aLkQGS2oB8I43vcDTSmEw=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.115/go.mod h1:2FThDhi9IFpRv/l/L4BQJM2+Az8TYdq7tFycTPGOuFY=
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
Expand Down
123 changes: 97 additions & 26 deletions router-tests/apollo_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"encoding/json"
"github.com/stretchr/testify/assert"
"net/http"
"testing"

Expand Down Expand Up @@ -37,8 +38,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"criteria":{"nationality":"GERMAN"}}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Invalid __typename found for object at array element of type Employee at index 0.","path":["findEmployees",0],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Invalid __typename found for object at array element of type Employee at index 0.","path":["findEmployees",0],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("enable value completion", func(t *testing.T) {
Expand All @@ -65,8 +66,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"criteria":{"nationality":"GERMAN"}}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Invalid __typename found for object at array element of type Employee at index 0.","path":["findEmployees",0],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Invalid __typename found for object at array element of type Employee at index 0.","path":["findEmployees",0],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("float compaction off", func(t *testing.T) {
Expand All @@ -86,8 +87,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"arg":1.0}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":{"floatField":1.0}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":{"floatField":1.0}}`, res.Body)
})
})
t.Run("should not truncate - off", func(t *testing.T) {
Expand All @@ -107,8 +108,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"arg":1.1}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":{"floatField":1.1}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":{"floatField":1.1}}`, res.Body)
})
})
t.Run("should not truncate - on", func(t *testing.T) {
Expand All @@ -135,8 +136,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"arg":1.1}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":{"floatField":1.1}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":{"floatField":1.1}}`, res.Body)
})
})
t.Run("float compaction on", func(t *testing.T) {
Expand All @@ -163,8 +164,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"arg":1}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":{"floatField":1}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":{"floatField":1}}`, res.Body)
})
})
t.Run("float compaction global", func(t *testing.T) {
Expand All @@ -189,8 +190,8 @@ func TestApolloCompatibility(t *testing.T) {
Variables: json.RawMessage(`{"arg":1}`),
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":{"floatField":1}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":{"floatField":1}}`, res.Body)
})
})
t.Run("nullable array item with non-nullable array item field", func(t *testing.T) {
Expand All @@ -216,8 +217,8 @@ func TestApolloCompatibility(t *testing.T) {
Query: `query {employees{id}}`,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":{"employees":[null]},"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Employee.id.","path":["employees",0,"id"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":{"employees":[null]},"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Employee.id.","path":["employees",0,"id"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("non-nullable array item", func(t *testing.T) {
Expand All @@ -243,8 +244,8 @@ func TestApolloCompatibility(t *testing.T) {
Query: `query {products{... on Consultancy{upc}}}`,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable array element of type Products at index 0.","path":["products",0],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable array element of type Products at index 0.","path":["products",0],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("non-nullable array item with non-nullable array item field", func(t *testing.T) {
Expand All @@ -270,8 +271,8 @@ func TestApolloCompatibility(t *testing.T) {
Query: `query {products{... on Consultancy{upc}}}`,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Products.upc.","path":["products",0,"upc"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Products.upc.","path":["products",0,"upc"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("simple fetch with suppress fetch errors enabled", func(t *testing.T) {
Expand Down Expand Up @@ -300,8 +301,8 @@ func TestApolloCompatibility(t *testing.T) {
Query: `query {products{... on Consultancy{upc}}}`,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Query.products.","path":["products"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Query.products.","path":["products"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("simple fetch with suppress fetch errors disabled", func(t *testing.T) {
Expand Down Expand Up @@ -330,8 +331,8 @@ func TestApolloCompatibility(t *testing.T) {
Query: `query {products{... on Consultancy{upc}}}`,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"errors":[{"message":"Failed to fetch from Subgraph 'employees', Reason: no data or errors in response.","extensions":{"statusCode":200}}],"data":null}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"errors":[{"message":"Failed to fetch from Subgraph 'employees', Reason: no data or errors in response.","extensions":{"statusCode":200}}],"data":null}`, res.Body)
})
})
t.Run("should suppress errors when enable all is true", func(t *testing.T) {
Expand All @@ -355,8 +356,78 @@ func TestApolloCompatibility(t *testing.T) {
Query: `query {products{... on Consultancy{upc}}}`,
})
require.NoError(t, err)
require.Equal(t, http.StatusOK, res.Response.StatusCode)
require.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Query.products.","path":["products"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"data":null,"extensions":{"valueCompletion":[{"message":"Cannot return null for non-nullable field Query.products.","path":["products"],"extensions":{"code":"INVALID_GRAPHQL"}}]}}`, res.Body)
})
})
t.Run("enable replace undefined operation field error", func(t *testing.T) {
testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithApolloCompatibilityFlagsConfig(config.ApolloCompatibilityFlags{
ReplaceUndefinedOpFieldErrors: config.ApolloCompatibilityReplaceUndefinedOpFieldErrors{
Enabled: true,
},
}),
},
}, func(t *testing.T, xEnv *testenv.Environment) {
res, err := xEnv.MakeGraphQLRequest(testenv.GraphQLRequest{
Query: `query {employees{nonExistentField {id}}}`,
})
require.NoError(t, err)
assert.Equal(t, http.StatusBadRequest, res.Response.StatusCode)
assert.Equal(t, `{"errors":[{"message":"Cannot query \"nonExistentField\" on type \"Employee\".","extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}]}`, res.Body)
})
})
t.Run("enable all: replace undefined operation field error", func(t *testing.T) {
testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithApolloCompatibilityFlagsConfig(config.ApolloCompatibilityFlags{
EnableAll: true,
}),
},
}, func(t *testing.T, xEnv *testenv.Environment) {
res, err := xEnv.MakeGraphQLRequest(testenv.GraphQLRequest{
Query: `query {employees{nonExistentField}}`,
})
require.NoError(t, err)
assert.Equal(t, http.StatusBadRequest, res.Response.StatusCode)
assert.Equal(t, `{"errors":[{"message":"Cannot query \"nonExistentField\" on type \"Employee\".","extensions":{"code":"GRAPHQL_VALIDATION_FAILED"}}]}`, res.Body)
})
})
t.Run("enable replace invalid variable error", func(t *testing.T) {
testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithApolloCompatibilityFlagsConfig(config.ApolloCompatibilityFlags{
ReplaceInvalidVarErrors: config.ApolloCompatibilityReplaceInvalidVarErrors{
Enabled: true,
},
}),
},
}, func(t *testing.T, xEnv *testenv.Environment) {
res, err := xEnv.MakeGraphQLRequest(testenv.GraphQLRequest{
Query: `query FloatQuery($arg: Float) { floatField(arg: $arg) }`,
Variables: json.RawMessage(`{"arg":"INVALID"}`),
})
require.NoError(t, err)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"errors":[{"message":"Variable \"$arg\" got invalid value \"INVALID\"; Float cannot represent non numeric value: \"INVALID\"","extensions":{"code":"BAD_USER_INPUT"}}]}`, res.Body)
})
})
t.Run("enable all: replace invalid variable error", func(t *testing.T) {
testenv.Run(t, &testenv.Config{
RouterOptions: []core.Option{
core.WithApolloCompatibilityFlagsConfig(config.ApolloCompatibilityFlags{
EnableAll: true,
}),
},
}, func(t *testing.T, xEnv *testenv.Environment) {
res, err := xEnv.MakeGraphQLRequest(testenv.GraphQLRequest{
Query: `query FloatQuery($arg: Float) { floatField(arg: $arg) }`,
Variables: json.RawMessage(`{"arg":"INVALID"}`),
})
require.NoError(t, err)
assert.Equal(t, http.StatusOK, res.Response.StatusCode)
assert.Equal(t, `{"errors":[{"message":"Variable \"$arg\" got invalid value \"INVALID\"; Float cannot represent non numeric value: \"INVALID\"","extensions":{"code":"BAD_USER_INPUT"}}]}`, res.Body)
})
})
}
Loading

0 comments on commit 8af0dca

Please sign in to comment.