lacinia icon indicating copy to clipboard operation
lacinia copied to clipboard

Modify federation to be possible with edn schema as well

Open hmy3743 opened this issue 3 years ago • 5 comments
trafficstars

Extends lacinia's support for federation to add the ability to support federation through the edn schema as well.

hmy3743 avatar Aug 08 '22 14:08 hmy3743

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 08 '22 14:08 CLAassistant

As I understand the Apollo federation documentation, the @extends and other directive, scalar types, etc. are not explicit in the input SDL but still available, and should not be generated into the output SDL. In the systems I've developed under federation, we start with SDL document and provided that document, as is ... you can see that in the code in master.

I am not sure if I understand the review comment well, but if you look at the document about apollo's federation subgraph, it says that the server should provide some schemas. Then shouldn't the schema be exposed to the router through query{_service{sdl}}}?

hmy3743 avatar Aug 28 '22 02:08 hmy3743

I'll work on resolving this against the Apollo documentation.

hlship avatar Aug 28 '22 17:08 hlship

Federation is a moving target, we're compatible with 1.0, but 2.0 changes things: https://www.apollographql.com/docs/federation/federated-types/federated-directives

In any case, I don't think the current version of this code will work because it includes the Federation (1.0) annotations and objects injected into the schema.

In the current version, based on reading SDL, you can see that those elements aren't in the input SDL (they are provided after that is parsed) and then we use the input SDL as-is when exposing the schema to the Apollo gateway.

I don't know exactly what would happen if we include those elements in the generated SDL but I suspect Apollo will reject the schema.

hlship avatar Sep 02 '22 16:09 hlship

I'm struggling to find time to come back and finish reviewing this. I want to test what happens when the injected Fed 1.0 directives and types are not filtered out when generating SDL from the schema (that is, see how Apollo reacts).

hlship avatar Dec 01 '22 22:12 hlship