Is it possible to specify a type that implements multiple interfaces within a GraphQL schema? If so, how would this be accomplished?
相关问题
- Gatsby - Pass state property to GraphQL query vari
- Apollo GraphQL Mutation (Object Argument)
- graphql multiple mutations using prior mutation re
- Error: field type must be Input Type - cannot pass
- @client Apollo GQL tag breaks query
相关文章
- Apollo Client Cache vs. Redux
- Reactjs/Apollo/AppSync Mutation Optimistic Respons
- How to fetch and display item by id using Relay co
- How to PUT / UPDATE nested data with GraphQL?
- How to execute Java calls to GraphQL in a Spring B
- Dynamic mutation document for react-apollo
- How do I logically split up my GraphQL schema and
- How do I upload files to a graphql backend impleme
I think yes, it should be possible as the specification describes on http://facebook.github.io/graphql/June2018/#sec-Interfaces.
Here is the example.
It seems comma separating the interfaces doesn't work anymore. I had to use "&" instead to make it work (Apollo), see this answer https://stackoverflow.com/a/49521662/1959584
Yes. As outlined in the spec:
Keep in mind that the resulting object must be a "super-set of all interfaces it implements" -- it must implement all the fields each interface has and these fields cannot conflict. For example, if Interface A and Interface B both have a field called
something
, the type of that field must be the same for both interfaces in order for an Object Type to implement both interfaces.Here's a simple example that you can open in CodeSandbox and play around with.
Note: As others have pointed out, using a comma to separate the interfaces is no longer supported -- please use an
&
(ampersand) instead.