在将苦艾酒从 1.4.12 升级到 1.5.2,将 ecto 从 2.1 升级到 3.0 并将数据加载器从 1.0.2 升级到 1.0.7 之后,我遇到了一些数据加载器无法批量查找项目的问题。我尝试按照 deepankar-j 在https://github.com/absinthe-graphql/absinthe/issues/746上指出的步骤来查看是否有相关内容并到达修复 use_parent: false 作为默认问题的 PR (https://github.com/absinthe-graphql/absinthe/pull/891)但无法解决我的问题。
我完全按照文档应用数据加载器来避免 N+1。
一些进一步的细节:当我在我的应用程序中查询特定字段时,批处理“中断”。这就是我应用数据加载器并使用结果进行排序的方式。查询该字段时:
operations {
id
}
像这样实现:
field :operations, list_of(:theme_clothing_operation), resolve: dataloader(Db,
:theme_clothing_operations, callback: fn(operations, _parent, _args) ->
{:ok, operations |> Enum.sort_by(fn(operation) -> operation.id end)}
end
)
但是当我删除该字段查询时,它可以工作。我不确定我是否提供了足够的详细信息,或者是否可以通过某种方式仅提供帮助,但我非常感谢一些帮助或一些可能发生的事情的线索。