Skip to content

How to fetch association from field datafetcher #21

Answered by paulbakker
marceloverdijk asked this question in Q&A
Discussion options

You must be logged in to vote

I think I understand the problem; to be able to load the director you need a field that your internal datas structure has, but is not represented in the schema, and thus not on the generated type.
If you return an instance of the generated type from the shows data fetcher, that's what you get back from getSource.

This problem is introduced because the director data fetcher requires context that's only available in the shows data fetcher. I'm sure there are multiple ways to get this to work, but my first approach would be to create a DataLoader to load directors, and invoke that data loader from within the shows data fetcher where you still have the directorId.

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
10 replies
@marceloverdijk
Comment options

@paulbakker
Comment options

@marceloverdijk
Comment options

@driptaroop
Comment options

@willyxiao
Comment options

Answer selected by marceloverdijk
Comment options

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

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants