Reputation: 1553
actually, all my queries have no filter, just retrieve all the records from the tables
I've read this link: https://github.com/graphql/graphql-js/issues/640
it's about building a manual filter, but the discussion doesn't end with a clear solution.
there is a way to in apollo client, to send a parameter to a query?
in mutation I use, but I have doubt about using the query
one query is by example:
query TourList {
tours {
id
name
price
country
seatsmax
seatsmin
datestart
dateend
organizer_id
}
}
how to filter by organizer_id ? I'm using sequelize ...
Upvotes: 1
Views: 2882
Reputation: 977
You provide the organizer_id
to your resolver, through the arguments, and do the filtering there. Something like this:
query TourList {
tours(oid: 1) {
id
name
price
...
}
}
// type definitions:
Query {
tours(oid: Int): [Tour!]!
}
// tours resolver:
tours: (obj, args, ctx, info) => {
// logic to get and return the filtered tours
}
You can use variables the same way you are doing with your mutations
Upvotes: 1