Created
November 5, 2016 18:01
-
-
Save MartinElvar/f1de589fc752463c859616fbe5763ecb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule ApiEndpoint.Endpoint do | |
# .... | |
plug Absinthe.Plug, | |
schema: ApiEndpoint.Schema | |
end | |
defmodule ApiEndpoint.Router do | |
forward "/api/v2", Absinthe.Plug, schema: ApiEndpoint.Schema | |
end | |
defmodule ApiEndpoint.Schema do | |
use Absinthe.Schema | |
import_types Users.Types | |
import_types Storages.Types | |
query do | |
field :storages, list_of(:storage) do | |
resolve &Storages.StorageResolver.all/2 | |
end | |
field :storage, type: :storage do | |
arg :id, non_null(:id) | |
resolve &Storages.StorageResolver.one/2 | |
end | |
field :user, type: :user do | |
arg :id, non_null(:id) | |
resolve &Users.UserResolver.one/2 | |
end | |
end | |
end | |
== Compilation error on file web/router.ex == | |
** (ArgumentError) The supplied schema: ApiEndpoint.Schema is not a valid Absinthe Schema | |
lib/absinthe/plug.ex:50: Absinthe.Plug.get_schema/1 | |
lib/absinthe/plug.ex:38: Absinthe.Plug.init/1 | |
(phoenix) lib/phoenix/router/route.ex:112: Phoenix.Router.Route.build_pipes/1 | |
(phoenix) lib/phoenix/router/route.ex:88: Phoenix.Router.Route.build_dispatch/2 | |
(phoenix) lib/phoenix/router/route.ex:56: Phoenix.Router.Route.exprs/1 | |
(phoenix) lib/phoenix/router.ex:281: Phoenix.Router."-MACRO-__before_compile__/2-fun-0-"/1 | |
(elixir) lib/enum.ex:1184: Enum."-map/2-lists^map/1-0-"/2 | |
(phoenix) expanding macro: Phoenix.Router.__before_compile__/1 | |
web/router.ex:1: ApiEndpoint.Router (module) | |
(elixir) lib/kernel/parallel_compiler.ex:117: anonymous fn/4 in Kernel.ParallelCompiler.spawn_compilers/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment