Skip to content

Commit

Permalink
fix: merging response nodes (#772)
Browse files Browse the repository at this point in the history
- fix merging response nodes issue leading to "non-nullable field can't
be null" errors
- fix duplicated fetches on complex abstract types queries
- add fetch input to trace for skipped fetches
  • Loading branch information
devsergiy authored May 27, 2024
1 parent 9eaed3b commit 5e89693
Show file tree
Hide file tree
Showing 41 changed files with 2,942 additions and 519 deletions.
21 changes: 17 additions & 4 deletions execution/engine/federation_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import (
"net/http"
"net/http/httptest"
"path"
"regexp"
"strings"
"testing"
"time"

"github.com/jensneuse/abstractlogger"
"github.com/sebdah/goldie/v2"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/wundergraph/graphql-go-tools/execution/federationtesting"
"github.com/wundergraph/graphql-go-tools/execution/federationtesting/gateway"
Expand Down Expand Up @@ -46,7 +49,6 @@ func testQueryPath(name string) string {
}

func TestFederationIntegrationTestWithArt(t *testing.T) {

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

Expand All @@ -55,12 +57,23 @@ func TestFederationIntegrationTestWithArt(t *testing.T) {

gqlClient := NewGraphqlClient(http.DefaultClient)

normalizeResponse := func(resp string) string {
rex, err := regexp.Compile(`http://127.0.0.1:\d+`)
require.NoError(t, err)
resp = rex.ReplaceAllString(resp, "http://localhost/graphql")
return resp
}

t.Run("single upstream query operation with ART", func(t *testing.T) {
resp := gqlClient.Query(ctx, setup.GatewayServer.URL, testQueryPath("queries/single_upstream.query"), nil, t)
respString := string(resp)
resp := gqlClient.Query(ctx, setup.GatewayServer.URL, testQueryPath("queries/complex_nesting.graphql"), nil, t)
respString := normalizeResponse(string(resp))

assert.Contains(t, respString, `{"data":{"me":{"id":"1234","username":"Me"}}`)
assert.Contains(t, respString, `{"data":{"me":{"id":"1234","username":"Me"`)
assert.Contains(t, respString, `"extensions":{"trace":{"info":{"trace_start_time"`)

buf := &bytes.Buffer{}
_ = json.Indent(buf, []byte(respString), "", " ")
goldie.New(t, goldie.WithNameSuffix(".json")).Assert(t, "complex_nesting_query_with_art", buf.Bytes())
})
}

Expand Down
Loading

0 comments on commit 5e89693

Please sign in to comment.