News for hackers. Stuff that matters.
Re:Introducing Yelp's GraphQL API by aamederen on Wednesday May 03, 2017 @07:34PM (#14261201)
Is it possible to do more complex requests in GraphQL, like getting the favorite venues of people that favored "Garaje" or is it left to the API provider?
Re:Introducing Yelp's GraphQL API by searchfaster on Wednesday May 03, 2017 @08:03PM (#14261361)
Yes.. Its left to the API provider.

Try https://learngraphql.com gives a very good idea of what graphql is. Way better than reading the official documentation or spec.

Once I went through it, made up my mind that our API as a service product should support Graphql.

Note: I am in no way related to the site.. It is free and I finally actually understood what graphql is in 15 mins.

Re:Introducing Yelp's GraphQL API by SmellTheGlove on Thursday May 04, 2017 @09:23AM (#14264596)
Thanks for sharing that link, looks really good. I'll be going through it after work.
Re:Introducing Yelp's GraphQL API by derekdahmer on Wednesday May 03, 2017 @08:03PM (#14261363)
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
      }
    }
  }
Re:Introducing Yelp's GraphQL API by infogulch on Wednesday May 03, 2017 @08:10PM (#14261397)
You 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
        }
      }
    }
  }
Re:Introducing Yelp's GraphQL API by sleepingeights on Thursday May 04, 2017 @03:20AM (#14263130)
GraphQL 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")

      }
Re:Introducing Yelp's GraphQL API by linkmotif on Wednesday May 03, 2017 @07:56PM (#14261327)
Left to the API provider. The provider specifies arguments you can provide per field. You can call those arguments.