small medium large xlarge

Photo1_pragsmall
08 Sep 2017, 14:21
Bruce Williams (15 posts)

This forum is for discussions about the book “Craft GraphQL APIs in Elixir with Absinthe.”

We look forward to hearing from you!

Generic-user-small
21 Sep 2017, 13:31
turbofail (1 post)

Hi,

in chapter 6, in “Setting up Subscriptions”, in snippet 06-chp.subscriptions/1-start/lib/plate_slate_web/channels/user_socket.ex, just indicated to add use Absinthe.Phoenix.Socket, schema: PlateSlateWeb.Schema.

But this cause an exception in absinthe_phoenix (Absinthe.Phoenix.Channel) because no absinthe config:

[error] an exception was raised:
    ** (BadMapError) expected a map, got: nil
        (elixir) lib/map.ex:424: Map.get(nil, :opts, [])
        (absinthe_phoenix) lib/absinthe/phoenix/channel.ex:24: Absinthe.Phoenix.Channel.join/3
        (phoenix) lib/phoenix/channel/server.ex:188: Phoenix.Channel.Server.init/1
        (stdlib) gen_server.erl:365: :gen_server.init_it/2
        (stdlib) gen_server.erl:333: :gen_server.init_it/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

.

To add absinthe config, put {:ok, assign(socket, :absinthe, %{schema: PlateSlateWeb.Schema})} in connect function to solve the problem.

I put it here for anyone with the same problem

You must be logged in to comment