Skip to content

Fields on interface fragment spreads don't get resolved #922

Closed
@LucasPickering

Description

@LucasPickering

Describe the bug

When resolving fields defined on an interface, if the field is defined within a fragment spread, then it is omitted from the output.

I'm happy to work on a fix for this, but will need some guidance on where to look (and whatever other tips/hints you could give me).

To Reproduce

Using the schema defined in juniper/src/tests/fixtures/starwars/ (I ran the juniper_rocket_async example to reproduce):

Working

A simple query returns the expected result (id and name fields are populated).

query {
  hero {
    id
    name
  }
}
{
  "data": {
    "hero": {
      "id": "2001",
      "name": "R2-D2"
    }
  }
}

Broken

But this query, using a fragment spread on the Character interface, is broken (id and name fields are omitted in the response):

{
  hero {
    ... on Character {
      id
      name
    }
  }
}
{
  "data": {
    "hero": {}
  }
}

Expected behavior

The second query above should return the exact same output as the first query.

Additional context

I encountered this problem using Relay in my UI, as parts of the query being generated by Relay use this pattern. Which leads me to believe that these queries should definitely be valid.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions