Dilute v0.1.0 Dilute View Source

Absinthe objects can be defined inside your Types module:

defmodule MyAppWeb.Schema.Types do
  use Absinthe.Schema.Notation
  require Dilute
  alias MyApp.Blog.{Post, Comment}

  Dilute.object(Post)
  Dilute.object(Comment)
end

Once the types are defined the resolver can be defined as:

defmodule MyAppWeb.Resolver do
  user Dilute.Resolver, types: MyAppWeb.Schema.Types, repo: MyApp.Repo
end

Querys can either be defined using the resolve/3 function or user the query_fields/2 macro

query do

@desc "Get all Posts"
field :posts, list_of(:post) do
  resolve(&MyAppWeb.Resolver.resolve/3)
end

query do
  MyWebApp.Schema.query_fields(:post, &Resolver.resolve/3)
end

end

Link to this section Summary

Functions

Defines an Absinthe object based on the ecto schema of the given module

Link to this section Functions

Link to this macro object(module) View Source (macro)

Defines an Absinthe object based on the ecto schema of the given module.

Fields can be excluded by including the respective field in the @exclude attribute:

@exclude [
  # ...
  {User, [:email, :forename]}
  # ...
]

Dilute.object(User)