Skip to content

Commit

Permalink
Clarify the dataloader integration (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanl authored Jun 13, 2021
1 parent 6269157 commit fe02d15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions guides/batching.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ defmodule MyApp.Blog do
end
```

In this example, the query returned by `query/2` is used as a starting point by Dataloader to build the final query, which it does by traversing schema associations.
In other words, Dataloader can determine that an author has many posts, and that to retrieve posts it needs to get those with the relevant `author_id`.
If that's sufficient for your needs, `query/2` need not modify the query it's given.
But if you only want to load published posts, `query/2` can narrow the query accordingly.

When integrating Dataloader with GraphQL, we want to place it in our context so
that we can access it in our resolvers. In your schema module add:

Expand Down
5 changes: 5 additions & 0 deletions guides/dataloader.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ defmodule MyApp.Blog do
end
```

In this example, the query returned by `query/2` is used as a starting point by Dataloader to build the final query, which it does by traversing schema associations.
In other words, Dataloader can determine that an author has many posts, and that to retrieve posts it needs to get those with the relevant `author_id`.
If that's sufficient for your needs, `query/2` need not modify the query it's given.
But if you only want to load published posts, `query/2` can narrow the query accordingly.

When integrating Dataloader with GraphQL, we want to place it in our context so
that we can access it in our resolvers. In your schema module add:

Expand Down

0 comments on commit fe02d15

Please sign in to comment.