kratam
08/30/2018, 8:57 AMprisma-binding
, the returned elements (obviously) doesn't have the field. But what if I want to use the resolved value/field e.g. for sorting or filtering the Response? In other words, is there a place where I can modify the response of a resolver after every sub-resolvers finished?nilan
08/30/2018, 10:59 AMkratam
08/30/2018, 12:49 PMdatamodel.graphql
type Item {
id: ID! @unique
foo: String!
}
schema.graphql
type Query {
search(something: String!): [Item!]!
}
type Item {
id: ID!
foo: String!
bar: String # <-- only in schema
}
Item.js
export const Item = {
bar: async () => {
return await someThingAsync()
}
}
Query.js
export const Query = {
search: async (parent, args, ctx, info) => {
const items = await ctx.db.query.items({}, info)
// this won't work, bar resolver will run in the future
return items.filter(item => item.bar === args.something)
}
}
nilan
08/30/2018, 12:59 PMkratam
08/30/2018, 2:33 PMkratam
08/30/2018, 2:42 PMfilter
) and another which would query the first, so I'd be able to do something like this in the second:
// info is the same so no extra fields are requested from the db
const resolvedItemsWithBar = await Query.firstSearch(info: info)
return resolvedItemsWithBar.filter(item => item.bar === args.something)
Can a resolver query another resolver with the same info
?