federation icon indicating copy to clipboard operation
federation copied to clipboard

Type with no fields

Open jeffjakub opened this issue 2 years ago • 1 comments

Issue Description

If a subgraph has a single field that is overridden, when we run extractSubgraphFromSupergraph it will create a type with no fields which causes a problem. I think the right thing is to just put the field back if there is an overridden field.

Link to Reproduction

n/a

Reproduction Steps

No response

jeffjakub avatar Jul 14 '23 16:07 jeffjakub

I had an idea to just go ahead and add the fields back in if they had been overridden, which shouldn't be a big deal, but there's a couple of problems.

  1. Just because there is a reference to an overridden field doesn't mean that the field actually existed. It could have been removed, but the @override still exists in the other subgraph. It's not possible to know whether it existed in the original subgraph or not, so @override fails reversibility.
  2. I had a thought to just add it to the type if it exists, and ignore it otherwise. The problem with this approach is that we are going to generate query plans and then validate them against the original graphql subgraph schema. So a query that passes against the supergraph might fail against a subgraph if we've post facto injected a field.

clenfest avatar Jul 14 '23 18:07 clenfest