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

FieldResult should "bubble up" in case of an error when the field is declared as Non-Null #84

Closed
rushmorem opened this issue Aug 14, 2017 · 7 comments
Labels
blocker p::critical Critical priority for implementation
Milestone

Comments

@rushmorem
Copy link
Contributor

The spec says:

If the field which experienced an error was declared as Non-Null, the null result will bubble up to the next nullable field. In that case, the path for the error should include the full path to the result field where the error occurred, even if that field is not present in the response.

This is not the current behaviour. Currently the null does not "bubble up". As a result, a field that was declared Non-Null will return a null when that field produces an error.

@mhallin mhallin added blocker p::critical Critical priority for implementation labels Aug 15, 2017
@mhallin mhallin added this to the 0.9 milestone Aug 15, 2017
@jacobh
Copy link
Contributor

jacobh commented Nov 14, 2017

Any progress on this one? It bit us today. Happy to help where possible

@rushmorem
Copy link
Contributor Author

Any progress on this one?

I don't know if anyone is currently working on this.

/cc @mhallin

@mhallin
Copy link
Member

mhallin commented Nov 18, 2017

This issue has been resolved on the master branch and will be part of the next release.

@theduke theduke closed this as completed Nov 19, 2017
@jacobh
Copy link
Contributor

jacobh commented Nov 19, 2017

Wonderful, thanks @mhallin !

@jacobh
Copy link
Contributor

jacobh commented Nov 20, 2017

I think there's still an issue here for array fields.

I've got a schema that looks like

schema {
  query: Query
  mutation: Mutations
}

# DateTime
scalar DateTimeUtc

type Query {
  queueEntry(id: Uuid!): QueueEntry
  session(id: Uuid!): Session
}

type QueueEntry {
  id: Uuid!
  session: Session!
}

type Session {
  id: Uuid!
  queueEntries: [QueueEntry!]!
}

# Uuid
scalar Uuid

I've modified the QueueEntry.session field to intentionally break it, and when looking up a specific QueueEntry this change works as expected

{
  queueEntry(id: "f01f415f-42fc-4e49-9600-56227e2edd96") {
    id
    session {
      id
    }
  }
}
{
  "data": {
    "queueEntry": null
  },
  "errors": [
    {
      "message": "Fake Error",
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ],
      "path": [
        "queueEntry",
        "session"
      ]
    }
  ]
}

However, when I query a Session, and get the list of related QueueEntrys, I get an array of nulls

{
  session(id: "9cc55702-6c3e-491e-b259-e8c6982c6073") {
    id
    queueEntries {
      id
      session {
        id
      }
    }
  }
}
{
  "data": {
    "session": {
      "id": "9cc55702-6c3e-491e-b259-e8c6982c6073",
      "queueEntries": [
        null,
        null,
        null
      ]
    }
  },
  "errors": [
    {
      "message": "Fake Error",
      "locations": [
        {
          "line": 9,
          "column": 7
        }
      ],
      "path": [
        "session",
        "queueEntries",
        "session"
      ]
    },
    {
      "message": "Fake Error",
      "locations": [
        {
          "line": 9,
          "column": 7
        }
      ],
      "path": [
        "session",
        "queueEntries",
        "session"
      ]
    },
    {
      "message": "Fake Error",
      "locations": [
        {
          "line": 9,
          "column": 7
        }
      ],
      "path": [
        "session",
        "queueEntries",
        "session"
      ]
    }
  ]
}

I'm using the latest master commit bee88d4

@mhallin
Copy link
Member

mhallin commented Nov 20, 2017

Thanks for reporting and creating a test case for this! Cases where we deviate from the spec are serious issues, so please keep reporting these if you find more :)

The non-nullable list issue should be resolved now, the test case you created passes on master.

@jacobh
Copy link
Contributor

jacobh commented Nov 20, 2017

That patch has done the trick! thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker p::critical Critical priority for implementation
Projects
None yet
Development

No branches or pull requests

4 participants