Subgraph Implementation Detailed Specification

Hi recently I submitted a PR in the Dgraph project to fix a bug with mis-matched data coming back from the gateway when Dgraph is a subgraph: fix(federation): sort hex number ID type correctly by JLaferri · Pull Request #8123 · dgraph-io/dgraph · GitHub

I found what I think should be the spec for how to implement a subgraph but I write this post primarily because I feel like there are some things missing. Apollo Federation subgraph specification - Federation - Apollo GraphQL Docs

Effectively my questions are:

  1. The spec does not seem to indicate that the _entities resolver need return the data in the same order it was passed into representations. Perhaps this is obvious but when key exists on the subgraph one could assume the gateway would handle the matching by key.
  2. What is the behavior if representations requests an object with a key that does not exist? Should the subgraph return null at that index? Does it matter if it doesn’t?
  3. Is it possible for the gateway to query entities with representations of different types in the same query? Dgraph seems to error in this case if I write a query manually, but in production I haven’t seen it happen yet?