You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to add a directive on an SomeType, which implements SomeInterface, the generated directive code behaves like this:
If a resolver returns []*SomeType, the directive also receives a []*SomeType variable as argument
func (ec*executionContext) _Query_todos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
//...resTmp, err:=ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
directive0:=func(rctx context.Context) (interface{}, error) {
ctx=rctx// use context from middleware stack in childrenreturnec.resolvers.Query().Todos(rctx)
}
directive1:=func(ctx context.Context) (interface{}, error) {
// ...// directive0 will return a slice of Todo, we cannot modify child context of each elementreturnec.directives.Scope(ctx, nil, directive0, scope)
}
// ...
})
// ...res:=resTmp.([]*model.Todo)
fc.Result=resreturnec.marshalNTodo2ᚕᚖgqlgenᚑtodosᚋgraphᚋmodelᚐTodoᚄ(ctx, field.Selections, res)
}
If a resolver's signature returns SomeInterface, and it returns SomeType , the directive is not called
func (ec*executionContext) _Query_node(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
// ...resTmp, err:=ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx=rctx// use context from middleware stack in childrenreturnec.resolvers.Query().Node(rctx, fc.Args["id"].(string))
// directive "scope" on "Todo" is not called at all
})
// ...res:=resTmp.(model.Node)
fc.Result=resreturnec.marshalONode2gqlgenᚑtodosᚋgraphᚋmodelᚐNode(ctx, field.Selections, res)
}
What did you expect?
The generated directive will be called if the concrete type of resolver result is SomeType, with exactly one element
What happened?
I tried to add a directive on an SomeType, which implements SomeInterface, the generated directive code behaves like this:
What did you expect?
The generated directive will be called if the concrete type of resolver result is SomeType, with exactly one element
Minimal graphql.schema and models to reproduce
versions
go run github.com/99designs/gqlgen version
: v0.17.49go version
: go version go1.23.1 darwin/arm64The text was updated successfully, but these errors were encountered: