DEV Community

Discussion on: Getting Started with Apollo Federation and Gateway

Collapse
 
dmahajan1609 profile image
dmahajan1609

Hi Mandi,

I've been trying out Apollo Federation for a week now and your samples/demos have helped get a project and running so thank you! I had a couple use-cases that seem like aren't currently supported unless I'm missing to understand something.

I'll try to explain my problem using your example above.
Given the Film type,

  • How would we resolve an array of actors with a Film.id? This is with the assumption that we don't have access to the actors.id array within the Films dataset and need to use Film types primary key.
  • How would we resolve nested Objects of one entity from an extended entity? So in the following example, How can I resolve Film.person.phone (without calls to all APIs in the full chain of the Person: { _resolveReference()})? Thanks in advance!


const typeDefs = gql

type Person @key(fields: "pid") {
pid: ID!
firstName: String
lastName: String
address: String
contact: [Phone] <--- separate API call
hobbies: [Interest] <--- separate API call
}

type Phone @key (fields: "pid") {
pid: ID!
number: String
type: String
}

type Interest @key (fields: "pid") {
pid: ID!
name: String
type: String
}

extend type Query {
person(id: ID!): Person
people: [Person]
}
;