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 doesn't propagate up to non-null list with field resolver #1230

Closed
ktsymbal opened this issue Jun 29, 2020 · 3 comments
Closed

Null doesn't propagate up to non-null list with field resolver #1230

ktsymbal opened this issue Jun 29, 2020 · 3 comments
Labels

Comments

@ktsymbal
Copy link

ktsymbal commented Jun 29, 2020

What happened?

When a resolver of a non-null field in a type that is used in a null-null list of non-null elements returns null, null doesn't propagate up to the list, and then to data, but returns a null element in a list.

Example when Image(ctx context.Context, obj *Post) (*Image, error) returns nil, fmt.Errorf("error message")

{
  "errors": [
    {
      "message": "error message",
      "path": [
        "users",
        0,
        "posts",
        0,
        "image"
      ]
    }
  ],
  "data": {
    "users": [
      {
        "name": "Nate",
        "posts": [
          null
        ]
      }
    ]
  }
}

What did you expect?

According to the spec, null should be propagated up to the first nullable field.

With this example:

{
  "errors": [
    {
      "message": "error message",
      "path": [
        "users",
        0,
        "posts",
        0,
        "image"
      ]
    }
  ],
  "data": null
}

Minimal graphql.schema and models to reproduce

type User {
        name: String!
        posts: [Post!]!
}

type Post {
        title: String!
        image: Image! @goField(forceResolver: true)
}

type Image {
        name: String!
}

type Query {
        users: [User!]!
}

directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION
    | FIELD_DEFINITION

versions

  • gqlgen version?
    v0.11.3
  • go version?
    v1.14.3
  • dep or go modules?
    go modules
@stale
Copy link

stale bot commented Sep 28, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 28, 2020
@stale stale bot closed this as completed Oct 5, 2020
@bofia
Copy link

bofia commented Nov 13, 2020

Not stale, seems like a open bug still

@TuringJest
Copy link

TuringJest commented Oct 29, 2021

This has good potential to break frontends. Has this already been fixed?

Edit: just upgraded to v0.14.0 and it's fixed now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants