diff --git a/graphql/extension/README.md b/graphql/extension/README.md index f94bcc4..0525a6b 100644 --- a/graphql/extension/README.md +++ b/graphql/extension/README.md @@ -11,7 +11,7 @@ gqlServer.Use(RecursionLimitByTypeAndField(1)) ``` This allow only one of each "type.field" field access in a query. For following examples, -consider that both root `user` and `User.friends` returns a type `User` (although firends may return a list). +consider that both root `user` and `User.friends` returns a type `User` (although friends may return a list). Allows: ```graphql diff --git a/graphql/extension/extension.go b/graphql/extension/extension.go index 6d027a4..946fffd 100644 --- a/graphql/extension/extension.go +++ b/graphql/extension/extension.go @@ -65,7 +65,7 @@ func checkRecursionLimitByTypeAndField(rCtx recursionContext, typeName string, s if newCount > rCtx.maxRecursion { return gqlerror.Errorf("too many nesting on %s.%s", nesting.parentTypeName, nesting.childFieldName) } - rCtx.typeAndFieldCount[nesting] += newCount + rCtx.typeAndFieldCount[nesting] = newCount err := checkRecursionLimitByTypeAndField(rCtx, collectedField.Definition.Type.Name(), collectedField.SelectionSet) if err != nil { return err diff --git a/graphql/extension/extension_test.go b/graphql/extension/extension_test.go index 5982d0b..a4a7921 100644 --- a/graphql/extension/extension_test.go +++ b/graphql/extension/extension_test.go @@ -7,7 +7,7 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/executor" - "github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" "github.com/vektah/gqlparser/v2/gqlerror" @@ -62,7 +62,7 @@ func TestRecursionLimitByTypeAndField(t *testing.T) { Query: queries, OperationName: tt.operationName, }) - require.Equal(t, err, tt.expectedErr) + assert.Equal(t, tt.expectedErr, err) }) } } @@ -72,7 +72,7 @@ var sources = []*ast.Source{ } var parsedSchema = gqlparser.MustLoadSchema(sources...) -var _ graphql.ExecutableSchema = &executableSchema{} +var _ graphql.ExecutableSchema = executableSchema{} type executableSchema struct{}