24 ms·
Not really. GraphQL mostly provides an alternative to REST when you want to select specific fields and traverse down into relationships with a single query. T
by derekdahmer 9y ago
Not really. GraphQL mostly provides an alternative to REST when you want to select specific fields and traverse down into relationships with a single query.
The closest you could get is the users who rated the business:
business(id: "garaje-san-francisco") {
reviewers {
rating
user {
name
}
}
}
If Yelp wanted to enable that use case, they would add a field to Business like `related_businesses` like:
business(id: "garaje-san-francisco") {
related_businesses {
business {
name
}
}
}
- infogulch 9y agoYou can recurse in GraphQL so if they added a `favorited_businesses` field to `user` then it would be possible. Something like this: business(id: "garaje-san-francisco") { reviewers { rating user { name favorited_businesses { id name } } } }
- sleepingeights 9y agoGraphQL looks cool, kind of fancy but simpler way to do some complex SQL without the SQL. Using the business as the root query would be a bit cumbersome, but more like: business(id: "garaje-san-francisco") { reviewers { user { name favorited_businesses favorited_businesses(name: "garaje") } } } If they provide user queries, then something like: user { name favorited_businesses favorited_businesses(name: "garaje") }