Skip to content

Support for spreading multiple fragments on types as well as on interfaces #183

@amsross

Description

@amsross

I encountered this using @reasonml-community/[email protected].

Spreading multiple fragments appears to work when the return type in question is an interface, but not when it is a concrete type. I've included a simple example below.

API Schema:

interface Node { id: ID! }
interface Actor { login: String }

type User implements Node & Actor {
  id: ID!
  login: String
}

type Query {
  """This Query returns a type, so spreading multiple fragments does not work"""
  user: User
  """This Query returns an interface, so spreading multiple fragments works"""
  actor: Actor
}

Working fragment/query combination:

[%graphql
  {|
    fragment NodeFragment on Node { id }
    fragment ActorFragment on Actor { login }

    query Query {
      user { ...ActorFragment }  <------ this could be NodeFragment instead but not both
      actor { ...NodeFragment ...ActorFragment }
    }
  |}
];

Non-working fragment/query combination:

[%graphql
  {|
    fragment NodeFragment on Node { id }
    fragment ActorFragment on Actor { login }

    query Query {
      user { ...NodeFragment ...ActorFragment }  <------ the addition of NodeFragment is the only difference
      actor { ...NodeFragment ...ActorFragment }
    }
  |}
];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions