federation icon indicating copy to clipboard operation
federation copied to clipboard

Supporting multiple @key s where some of them are nullable

Open bennyk8y opened this issue 2 years ago • 1 comments

Inside service vendors the entity looks like:

type Vendor @key(fields: "id") @key(fields: "integrationType") {
  id: ID!
  integrationType: IntegrationType
  name: String!
}

as you can see integrationType is nullable.

in other service, users , we want to reference Vendor which is defined this way:

type Vendor @key(fields: "integrationType", resolvable: false) @key(fields: "id", resolvable: false) {
  integrationType: IntegrationType
  id: ID!
}

we want to be able to resolve Vendor from users service by id in some cases and by integrationType in some other cases.

because the id of vendor defined as non-nullable in users, once referencing it by integrationType the query returns Cannot return null for non-nullable field Vendor.id..

Is this case of having nullable fields on entity even supported?

bennyk8y avatar Aug 02 '23 11:08 bennyk8y

Thanks for raising this issue! Could you provide a repo so we can reproduce this problem?

jeffjakub avatar Aug 09 '23 16:08 jeffjakub