Skip to content

How to "Join" to subgraphs? #5640

Answered by kamilkisiela
rawkode asked this question in Help
Discussion options

You must be logged in to vote

What GraphQL server are you using for the subgraph?

I will assume it's JS-based like https://the-guild.dev/graphql/yoga-server .

In the resolvers object:

{
  Person: {
    __resolveReference(key: { id: string }) {
      const shows = getShowsOfPerson(key.id);
      
      if (shows == null) { return null }
      
      return { id: key.id, shows };
      // if you prefer, you can also return `{ id }` and add `shows` function to the object (Person.shows()).
    }
  }
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rawkode
Comment options

Answer selected by rawkode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants