#use OR in graphQL query

1 messages · Page 1 of 1 (latest)

still sparrow
#

Can we use AND, OR syntax in the graphQL query? , some thing like this:

clients(
where: {
and: [{ name: { contains: "a" } }, { endDate: { gte: "2017-12-31" } }]
}
) {
id
name
endDate
reasonForEnding
}

nimble flax
#

you can do AND just be using multiple properties on the WHERE property

like this

query{
  posts(where:{
    title:{
      contains:"TechCrunch"     
    }
    content:{
      contains:"Since"
    }
  }){
    id
      title
    content
  }
}
#

but OR is not available

#

for your example:

clients(
where: {
name: { contains: "a" }
endDate: { gte: "2017-12-31" }
}
) {
id
name
endDate
reasonForEnding
}

still sparrow
#

Got it, thanks Yuval.

#

Do you have any plan to develop OR feature?

#

or you suggest us to develop it ourselves?

#

And if we want to achieve OR, do you have any workaround solution?

#

Thanks!

nimble flax
#

it should be easy to implement with custom code, since prisma already support OR, all you need to do is to expose the parameter to API with the current type...

we didnt implement it yet since it may impacts access permissions when a user may access data that is not theirs.. in our generic case it may be difficult to face that, but in your specific case that should be easy to work around

brazen mist