graphql-ppx
graphql-ppx copied to clipboard
Support for spreading multiple fragments on types as well as on interfaces
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 }
}
|}
];
Cool, thanks for the issue. We need a modification in fragment spreads to facilitate spreading fragments on interfaces.