diego086
08/31/2018, 8:14 PMasync placesWithFriends(parent, args, ctx, info) {
const id = getUserId(ctx)
const friends = await ctx.db.query.user({ where: { id } },
`{
friends{
friend{
id
}
}}`
)
let idsFriends = friends.friends.map(friend => friend.friend.id)
return ctx.db.query.places({ where: {
checkins_every:{
user:{
id_in: idsFriends
}
}
}}, info)
},
which the outcome is the same as this one:
query{
places(
where: {
checkins_some:{
user:{
id_in:["cxxxxxxxxxx8829pbcte3g", "cjlxxxxxxxxxx882zi7drfeh"] #ARRAY idsFriends
}
}
}
){
id
name
checkins{
user{
id
name
}
}
}
}
but im trying to set the "where" clause on the checkins like this
query{
places{
id
name
checkins(
where: {
user:{
id_in:["cjlxxxxxxxxxxnpt8osm", "cjle5yxxxxxxxxx82czmke786"] #ARRAY idsFriends
}
}
){
user{
id
name
}
}
}
}
i cannot do that exact query on the resolver because when i use "ctx.db.query.places({ where..." it will filter the places and i need ALL the places, what im trying to do is filter the checkins inside every place