Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: clarify the dataloader integration #1076

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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