Skip to content

Instantly share code, notes, and snippets.

@ianstormtaylor
Last active April 7, 2017 19:27
Show Gist options
  • Save ianstormtaylor/16b1fc96cb6411672d7a4c3bf3fd4a9f to your computer and use it in GitHub Desktop.
Save ianstormtaylor/16b1fc96cb6411672d7a4c3bf3fd4a9f to your computer and use it in GitHub Desktop.

In REST you might do a basic filter like...

GET /books?status=published

Which in GraphQL could be...

books(status: "published") {
  ...
}

And in REST you might do an include like...

GET /books/1?include=authors

Which in GraphQL could be...

book(id: 1) {
  ...
  authors {
    ...
  }
}

Trying to combine them in REST is typically not supported, and gets complex because you'd need to further invest parsing logic to handle things like...

GET /books?include=authors(filter.name:Kate)

Or something crazy like that.

But in GraphQL I think this is easier, since all of the relationships can take arguments, like...

books {
  ...
  authors(name: "Kate") {
    ...
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment