graphql-platform icon indicating copy to clipboard operation
graphql-platform copied to clipboard

Support for Apollo Federation @interfaceObject

Open cli00004 opened this issue 2 years ago • 4 comments

Product

Hot Chocolate

Is your feature request related to a problem?

Apollo Federation has introduced @interfaceObject which isn't supported in HotChocolate.ApolloFederation package. This is an import feature that not only reduces code duplication in subgraphs, but also help us provide capability to resolve a external interface reference in a polymorphic manner

The solution you'd like

Please add support for @interfaceObject and support resolving interface object type in subgraphs

cli00004 avatar May 26 '23 00:05 cli00004

I just ran across this today, and the overall issue I believe is not supporting Apollo Federation 2.0.

I wrote my own interfaceObject directive, and it was output in the schema, but then rover refused to merge the graphs because the one from HotChocolate didn't have a @link directive specifying it was using v2.0

darren-clark avatar May 28 '23 01:05 darren-clark

@darren-clark , Also we need the entity resolver to be able to resolve on the interface type which i don't think it's supported atm

cli00004 avatar May 28 '23 22:05 cli00004

It isn't. I fiddled a bit today to see if I could get something working with manually created schema for federation. Specifically trying to get an entity resolve for an interface to work.

I was able to get it to call a resolver for a base class. However even though the resolver returned a derived class, the response from HotChocolate was empty. Probably because the query was ... on BaseInterface { __typename field } and the resolver returned DerivedImplementation so they got removed.

darren-clark avatar May 28 '23 22:05 darren-clark

@michaelstaib I believe this is already supported so should this be closed?

dariuszkuc avatar Apr 09 '25 03:04 dariuszkuc

@dariuszkuc interface object is supported but there is no way to add reference resolvers on interfaces. So, technically you can make it work if the subgraph where the actual interface is defined isn't using Hot Chocolate.

rdb00 avatar Jun 30 '25 16:06 rdb00