Skip to content

Commit

Permalink
add bypass __schema field test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tsh96 committed Aug 7, 2021
1 parent 54cef3d commit 5adb73b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions graphql/handler/extension/complexity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ func TestFixedComplexity(t *testing.T) {
require.Equal(t, 2, stats.ComplexityLimit)
require.Equal(t, 4, stats.Complexity)
})

t.Run("bypass __schema field", func(t *testing.T) {
h.SetCalculatedComplexity(4)
resp := doRequest(h, "POST", "/graphql", `{ "operationName":"IntrospectionQuery", "query":"query IntrospectionQuery { __schema { queryType { name } mutationType { name }}}"}`)
require.Equal(t, http.StatusOK, resp.Code, resp.Body.String())
require.Equal(t, `{"data":{"name":"test"}}`, resp.Body.String())

require.Equal(t, 2, stats.ComplexityLimit)
require.Equal(t, 0, stats.Complexity)
})
}

func doRequest(handler http.Handler, method string, target string, body string) *httptest.ResponseRecorder {
Expand Down

0 comments on commit 5adb73b

Please sign in to comment.