Skip to content

Commit

Permalink
fix: recursion counting, other minor PR fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fazt01 committed Apr 22, 2024
1 parent 90a1df7 commit adfc84e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion graphql/extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion graphql/extension/extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions graphql/extension/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
})
}
}
Expand All @@ -72,7 +72,7 @@ var sources = []*ast.Source{
}
var parsedSchema = gqlparser.MustLoadSchema(sources...)

var _ graphql.ExecutableSchema = &executableSchema{}
var _ graphql.ExecutableSchema = executableSchema{}

type executableSchema struct{}

Expand Down

0 comments on commit adfc84e

Please sign in to comment.