Support in federation for unions

Hello everyone!

We are currently looking into migrating our service to a federated setup. However unions, pose a real problem for us right now. The problem is mainly in feeding the key to the underlying type. Below is an example of how we would like to do it, but are unable to at the moment, as unions are not allowed to have keys, I am unsure how to correctly key the objects that are needed.

Please note that product would come from a different service than User.

type User @key(fields: "product { id }") {
  userId: Int
  product: Response
}

# Adding a @key here does not work
union Response @key(fields: "id") = Error | Product

type Error @key(fields: "id") {
  id: String
}

type Product @key(fields: "id") {
  id: String
  name: String
}  
  • Does anyone know if this will be supported?
  • Are we doing something wrong here?
  • How would you circumvent this?
  • Should we delete unions altogether if we want to use a federated setup?

Any help is greatly appreciated! Thanks!

  • Kenneth
1 Like