0

My Schema:

 subscription do
    @desc "Subscribe to drawing change"
    field :drawing_change, :drawing do
      # arg(:drawing_id, non_null(:id))

      config(fn _args, _resolution ->
        {:ok, topic: "*"}
      end)
    end
  end

When I do

subscription {
  drawingChange {
    data
    name
  }
}

I get this error TypeError: Failed to fetch

Log:

[debug] Processing with Absinthe.Plug
  Parameters: %{"query" => "subscription {\n  drawingChange {\n    data\n    name\n  }\n}", "variables" => nil}
  Pipelines: [:api]
[debug] ABSINTHE schema=DrawingApiWeb.Schema.Schema variables=%{}
---
subscription {
  drawingChange {
    data
    name
  }
}
---
[info] Chunked 200 in 107ms

Here are my rest of the set up:

User socket: use Absinthe.Phoenix.Socket, schema: DrawingApiWeb.Schema.Schema

Endoint: use Absinthe.Phoenix.Endpoint

Router:

forward "/graphiql", Absinthe.Plug.GraphiQL,
      schema: DrawingApiWeb.Schema.Schema,
      socket: DrawingApiWeb.UserSocket

All this happens before I commit any change to any context. Whatever the issue is, it should be in the setup. I have followed the exact instruction in the Absinthe-GraphQL book and Pragmatic Studio Video, and I verified it with the https://hexdocs.pm/absinthe/subscriptions.html

Still the same error. Thank you for your help in advance.

Mr H
  • 5,254
  • 3
  • 38
  • 43

1 Answers1

1

I found it.

I did not set up ws://localhost:4000/socket in the Graphiql.

All good now. cheers

Mr H
  • 5,254
  • 3
  • 38
  • 43