Reputation: 8509
I did not work with GraphQL before the last days. I use Apollo Client with graphql-tag
. Now I can get the list of cities from a server with this query:
query {
cities(country:countryName, limit:30){
id
name
}
}
But I want to get only the cities which names (name
property) have an occurrence of the string that user typed. It should work like autocomplete. For example when user type san
I want to get array of objects for San Francisco, San Jose, San Juan...
. Is it possible to do it on the client side, or I should to ask the backend developer for it?
Upvotes: 0
Views: 493
Reputation: 977
The country
arguments should be a variable and it'll compute from the component's props.
query ($country: String) {
cities(country: $country, limit: 30) {
id
name
}
}
Your input should sit in the component's parent which will pass down the value through the country
prop.
Check out this sandbox for an example. You can see the schema and resolvers here
Upvotes: 3