In GraphQL, if I'm trying to resolve the Address or a Person, how do I get the Address ID?

Viewed 11

Consider this model:

type Address {
  id: ID!
}

type Person {
  id: ID!
  address: Address
}

I'm writing the resolver for Person->address to get the address of the person, which is in another DB table.

In order to do that, I need the addressId but I don't have it. The addressId property was available inside the Person resolver, but that was lost, since my GraphQL schema doesn't have an addressId.

How do I get the addressId inside the Person.address resolver?

PS:

One way I can do it, is to add an addressId to Person, but if I do that, I would have to add sibling IDs to all foreign keys in my GraphQL schema and this seems off. If that's the way to go, though, I'd do it

0 Answers
Related