I need some help with lacinia, i'm trying to return a list of objects using a query that has no params:
:drivers
[{:id "1"
:name "Tom Smith"
:email "<mailto:tom@google.com|tom@google.com>"}
{:id "2"
:name "Billy Blanks"
:email "<mailto:bill@email.com|bill@email.com>"}
{:id "3"
:name "Peter Pan"
:email "<mailto:peterpan@yahoo.com|peterpan@yahoo.com>"}
{:id "4"
:name "Greg Abott"
:email "<mailto:gregabott@gmail.com|gregabott@gmail.com>"}
{:id "5"
:name "Jill Tray"
:email "<mailto:jilltray@gmail.com|jilltray@gmail.com>"}
{:id "6"
:name "Mary Miles"
:email "<mailto:mmiles@uber.com|mmiles@uber.com>"}]
`My query:
:all_drivers
{:type (list :Driver)
:description "Get all the drivers"
:resolve :query/all-drivers}
}
and the resolver:
(defn resolver-map
[component]
(let [trips-data (-> (io/resource "trips-data.edn")
slurp
edn/read-string)
trips-map (entity-map trips-data :trips)
cars-map (entity-map trips-data :cars)
drivers-map (entity-map trips-data :drivers)]
{:query/trip-by-id (partial resolve-trip-by-id trips-map)
:query/drivers-by-id (partial resolve-drivers-by-id drivers-map)
:query/all-drivers resolve-all-drivers drivers-map
:Trip/cars (partial resolve-trip-cars cars-map)
:Car/trips (partial resolve-car-trips trips-map)}))
(defn resolve-all-drivers
[drivers-map context args value]
drivers-map)
Calling all_drivers
gives me this error:
{
"data": {
"all_drivers": null
},
"errors": [
{
"message": "Field resolver returned a single value, expected a collection of values.",
"locations": [
{
"line": 31,
"column": 3
}
],
"path": [
"all_drivers"
]
}
]
}
any idea what's going on?figured this out ' drivers-map (get trips-data :drivers)`
drivers-map (get trips-data :drivers)