Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null bubbles up to non-nullable array element #811

Closed
edsrzf opened this issue Jul 30, 2019 · 5 comments
Closed

Null bubbles up to non-nullable array element #811

edsrzf opened this issue Jul 30, 2019 · 5 comments
Labels
accepted bug Something isn't working

Comments

@edsrzf
Copy link
Contributor

edsrzf commented Jul 30, 2019

What happened?

I've defined a field in my schema that is an array of non-null elements ([T!]!). When an error occurs resolving one of the elements of the array, the null bubbles up to the element of the array rather than the next nullable field.

What did you expect?

Non-nullable elements should never be null. I expect the null to bubble up to the next nullable field, as defined in the specification.

Minimal graphql.schema and models to reproduce

There's a full repo with instructions here: https://github.com/edsrzf/gqlgen-null-repro

Schema:

type Todo {
  user: User!
}

type User {
  name: String!
}

type Query {
  todos: [Todo!]!
}

Resolvers:

package gqlgen_repro

import (
	"context"
	"errors"
)

type Resolver struct{}

func (r *Resolver) Query() QueryResolver {
	return &queryResolver{r}
}

func (r *Resolver) Todo() TodoResolver {
	return &todoResolver{r}
}

type queryResolver struct{ *Resolver }

func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) {
	return []*Todo{{}}, nil
}

type todoResolver struct{ *Resolver }

func (r *todoResolver) User(ctx context.Context, obj *Todo) (*User, error) {
	return nil, errors.New("oh no")
}

I used the models generated by gqlgen, but forced Todo.user to use a resolver.

versions

  • gqlgen version? 0.9.1
  • go version? 1.12.6
  • dep or go modules? Go modules
@vektah vektah added the bug Something isn't working label Aug 7, 2019
@vektah vektah added the accepted label Oct 1, 2019
@vvakame
Copy link
Collaborator

vvakame commented Dec 25, 2019

I confirmed this issue still occurred in v0.10.2 and master/HEAD (v0.10.3-0.20191128123652-f869f5a85385)

@NaLLiFFuNT
Copy link

any updates?

@wilhelmeek
Copy link
Contributor

I've raised a PR that addresses this behaviour here #1480. Not sure who the best people to loop in are though?

@wilhelmeek
Copy link
Contributor

The above PR's been merged, so this issue should now be resolved.

@arash16
Copy link

arash16 commented Aug 18, 2021

So is there going to be a new patch release? It's been months past by?!

@lwc lwc closed this as completed Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants