我的架构:
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当我这样做的时候
subscription {
drawingChange {
data
name
}
}我得到这个错误TypeError: Failed to fetch
日志:
[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下面是我剩下的设置:
用户套接字:use Absinthe.Phoenix.Socket, schema: DrawingApiWeb.Schema.Schema
结束:use Absinthe.Phoenix.Endpoint
路由器:
forward "/graphiql", Absinthe.Plug.GraphiQL,
schema: DrawingApiWeb.Schema.Schema,
socket: DrawingApiWeb.UserSocket所有这些都是在我提交任何上下文更改之前发生的。不管是什么问题,都应该在设置中。我遵循了Absinthe-GraphQL书和实用主义工作室视频中的确切说明,并通过https://hexdocs.pm/absinthe/subscriptions.html进行了验证
仍然是同样的错误。提前感谢您的帮助。
发布于 2020-02-10 11:54:10
我找到了。
我没有在Graphiql中设置ws://localhost:4000/socket。
现在都好了。干杯
https://stackoverflow.com/questions/60143699
复制相似问题