Need help with absinthe_ecto?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

129 Stars 33 Forks MIT License 44 Commits 7 Opened issues


DEPRECATED: Use dataloader

Services available


Need anything else?

Contributors list


DEPRECATED: Please use Dataloader.Ecto from the dataloader package instead.

Hex pmLicense

Provides some helper functions for easy batching of Ecto assocations

These functions all make use of the batch plugin found in Absinthe, they're merely just some helpful ways to use this plugin in the context of simple ecto associations.

Basic Usage

First specify the repo you're going to use:

use Absinthe.Ecto, repo: MyApp.Repo

Then, supposing you have some ecto associations as in this example schema: ```elixir defmodule MyApp.Post do use Ecto.Schema

schema "posts" do belongsto :author, MyApp.User hasmany :comments, MyApp.Comment field :name, :string field :body, :string end end ```

Your graphql post object might look like:

object :post do
  field :author, :user, resolve: assoc(:author)
  field :comments, list_of(:comment), resolve: assoc(:comments)
  field :name, :string
  field :body, :string

Now, queries which get the author or comments of many posts will result in just 1 call to the database for each!


macro just builds a resolution function which calls

See the

function for how to do this from within a regular resolution function.



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.