type Person {
firstName: String!,
lastName: String!,
age: Int!
}
How to query all people what are older than 18?
It probably depends on the backend you are using but e.g. in graph.cool you could something like this:
query {
allPersons(filter: {
age_gt: 18
}) {
firstName
lastName
}
}
If you are using Prisma as backend, you could use the greater than operator (_gt
), like so:
query {
persons(where: {age_gt: 18}) {
firstName
lastName
age
}
}
You can also use other operators like:
_gt
(greater than)_lt
(less than)_gte
(greater than or equal to)_lte
(less than or equal to)_in
(equal to)_not_in
(not equal to)They are compatible with any data types like Integer, Float, Double, Text, Boolean, Date, etc.
And libraries become part of other libraries and framework.They don't become framework
Right now to use graphql to full extend you can combine it with ORM'S like Hasura Or Graphile Or Prisma
query {
article(
where: {rating: {_gte: 4}}
) {
id
title
rating
}
}
query {
posts(where: {
AND: [{
title_in: ["My biggest Adventure", "My latest Hobbies"]
}]
}) {
id
title
}
}
Advice Do not use graphql directly/independently ,use it with above orm's
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With