【发布时间】:2019-08-05 22:47:06
【问题描述】:
我正在使用 lacinia+pedestal 来设置 graphql 服务,我在教程中看到的大多数查询都需要一个 arg (iD),例如games_by_id,但我想检索所有没有 arg 的对象:
(defn resolve-all-drivers
[drivers-map context args value]
drivers-map)
schema-data.edn
:all_drivers
{:type (list Driver)
:description "Get all the drivers"
:resolve :query/all-drivers}
}
架构:
:Driver {:description "A collection of drivers"
:fields {:id {:type (non-null ID)}
:name {:type (non-null String)}
:email {:type (non-null String)}}}
在 GraphiQL 中:
{
all_drivers {
name
}
}
知道如何更改它以给我一个没有 args 的完整列表吗?
【问题讨论】:
-
我会发现一个 API 非常令人困惑,它会在“x-by-id”上为您提供“所有 x”而没有 args。
-
我更新了查询以返回一个(列表驱动程序)并为它创建了一个新的查询+解析器
标签: clojure