Untitled
unknown
javascript
4 years ago
714 B
8
Indexable
const resolvers = {
// create the field resolvers here
name(obj) {
return (obj.firstName + " " + obj.lastName).trim()
},
books(obj, _args, { db }) {
const rows = db.execute(sql`
SELECT *
FROM book
WHERE visibility = 'PUBLIC' AND user_ref = ${obj.id} AND NOT deleted
ORDER BY updated_at DESC
`)
return rows.map(r => ({ ...r, _type: "published" }))
},
collections(obj, _args, { db }) {
const rows = db.execute(sql`
SELECT *
FROM collection
WHERE visibility = 'PUBLIC' AND user_ref = ${obj.id} AND NOT deleted
ORDER BY updated_at DESC
`)
return rows.map(r => ({ ...r, _type: "published" }))
},
}Editor is loading...