How to extend a type without a key

Hello everyone,
So this is not really a studio specific enquiry, I’ve a specific use case in mind.

So the thing I’m trying to accomplish is to publish a type which can be queried by anyone and this type simply gives you information about the API itself. What I want to do is introduce type called maybe ApiInfo, and each subgraph adds themself as a field and exposes their own information, I’d invision my type (when combined into supergraph) would look something like:

type ApiInfo {
  accounts {
    version: String!
  }
  payments {
    version: String!
  }
  cart {
    version: String!
  }
}

So that when debugging, we know which version of subgraph composes our supergraph schema. (Ignore the invalid syntax, you get the idea),

One way to do would be to add a id inside anyway and mark that as ID, but that kinda looks ugly, is that the only way? Or can I just extend without using the key?

Thanks in advance

Would it be easier to return custom headers for every request to the child service?

That way, if a query touches a specific service you can have a header for each version.

Alternatively, yes, you could make this type, but you’d likely need to stub it out somewhere, such as:

type ApiInfo {
  _unused: String
}
# Accounts service
extend type ApiInfo {
  accounts: AccountsApiInfo!
}

type AccountsApiInfo {
  version: String!
}

I don’t think you’d need to use @key or @external, because these objects have no foreign key relationship.

Thanks @kevin-lindsay-1 , this is definitely awesome, btw, is there a way to use managed federation, but add 1 resolver to the gateway which is exposed? I was thinking, ApiInfo itself would be exposed from Gateway, and it’d have it’s own version (we do version our gateway), and I could expose that,

Is there some docs on how to let gateway expose certain resolvers?

I’ve never tried adding resolvers directly to the gateway, and I’m not sure if there’s any docs for that use case.

I think a more supported option would be to have a special service that handles that type. Headers sound easier, though.