Skip to content

Cannot return null for non-nullable field #1288

@omahili

Description

@omahili

Let's say we have a subgraph that looks like this:

type Query {
   foo: Foo!
}

and when we send the following query to the gateway:

query {
   foo1: foo
   foo2: foo
}

Now let's say the aliased query foo1 fails with an error, the subgraph will respond with something like:

{
 "errors": [
    {
      "message": "Lorem ipsum.",
      "locations": [...],
      "path": ["_v0_foo"],
      "extensions": [...]
    }
  ],
  "data": null
}

We'd expect this response to be correctly returned from the gateway, however the graphql validation fails and the gateway throws this error:

Cannot return null for non-nullable field Query.foo.

We understand that due to the fact that foo is non nullable field partial responses are not allowed in this case, however since the root object data is returned as null we'd expect the response to be correctly returned in this case.

We're using hive as nestjs module:

@graphql-hive/nestjs: 1.0.15
graphql: 16.11.0

Are we missing something or is this actually a bug?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions