resources • HTTP verbs denote what is to be done with a resource • Leverages HTTP features (headers, status codes etc.) • HATEOAS (Hypertext As The Engine Of Application State)
resources • HTTP verbs denote what is to be done with a resource • Leverages HTTP features (headers, status codes etc.) • HATEOAS (Hypertext As The Engine Of Application State)
resources • HTTP verbs denote what is to be done with a resource • Leverages HTTP features (headers, status codes etc.) • HATEOAS (Hypertext As The Engine Of Application State)
resources • HTTP verbs denote what is to be done with a resource • Leverages HTTP features (headers, status codes etc.) • HATEOAS (Hypertext As The Engine Of Application State)
released in 2015 • Query language • Lots of tools and libraries to facilitate development of GraphQL-compatible APIs • Reference implementation in (server-side) Javascript
Get • Single endpoint for all requests (typically /graphql ) • Relies on own conventions instead of using HTTP ◦ All client requests are POST ◦ All server responses are 200 OK • Uses queries and mutations for fetching and modifying data • And much more!
Get • Single endpoint for all requests (typically /graphql ) • Relies on own conventions instead of using HTTP ◦ All client requests are POST ◦ All server responses are 200 OK • Uses queries and mutations for fetching and modifying data • And much more!
Get • Single endpoint for all requests (typically /graphql ) • Relies on own conventions instead of using HTTP ◦ All client requests are POST ◦ All server responses are 200 OK • Uses queries and mutations for fetching and modifying data • And much more!
Get • Single endpoint for all requests (typically /graphql ) • Relies on own conventions instead of using HTTP ◦ All client requests are POST ◦ All server responses are 200 OK • Uses queries and mutations for fetching and modifying data • And much more!
Get • Single endpoint for all requests (typically /graphql ) • Relies on own conventions instead of using HTTP ◦ All client requests are POST ◦ All server responses are 200 OK • Uses queries and mutations for fetching and modifying data • And much more!
Flexible in what requests it accepts • No clear consensus on how to evolve APIs • Returns entire resources (by default) GraphQL • One endpoint for everything • Limited to the query language • API evolution is easy w/ great tooling • What You Want Is What You Get
Flexible in what requests it accepts • No clear consensus on how to evolve APIs • Returns entire resources (by default) GraphQL • One endpoint for everything • Limited to the query language • API evolution is easy w/ great tooling • What You Want Is What You Get
Flexible in what requests it accepts • No clear consensus on how to evolve APIs • Returns entire resources (by default) GraphQL • One endpoint for everything • Limited to the query language • API evolution is easy w/ great tooling • What You Want Is What You Get
Flexible in what requests it accepts • No clear consensus on how to evolve APIs • Returns entire resources (by default) GraphQL • One endpoint for everything • Limited to the query language • API evolution is easy w/ great tooling • What You Want Is What You Get
REST • Clients receive data in a predefined structure • Easier to cache • Multiple API calls may be necessary • No information on which fields are actually used GraphQL • Clients receive data structured the way they need it • Less cache hits • Can fetch all data with a single API call • Granular information on which fields are used
REST • Clients receive data in a predefined structure • Easier to cache • Multiple API calls may be necessary • No information on which fields are actually used GraphQL • Clients receive data structured the way they need it • Less cache hits • Can fetch all data with a single API call • Granular information on which fields are used
REST • Clients receive data in a predefined structure • Easier to cache • Multiple API calls may be necessary • No information on which fields are actually used GraphQL • Clients receive data structured the way they need it • Less cache hits • Can fetch all data with a single API call • Granular information on which fields are used
REST • Clients receive data in a predefined structure • Easier to cache • Multiple API calls may be necessary • No information on which fields are actually used GraphQL • Clients receive data structured the way they need it • Less cache hits • Can fetch all data with a single API call • Granular information on which fields are used
is easy • HTTP verbs carry more semantic information • Clearly defined protocol for marking errors GraphQL • Cannot cache at the network level • Queries/mutations not as precise • Hard to infer errors programmatically
is easy • HTTP verbs carry more semantic information • Clearly defined protocol for marking errors GraphQL • Cannot cache at the network level • Queries/mutations not as precise • Hard to infer errors programmatically
is easy • HTTP verbs carry more semantic information • Clearly defined protocol for marking errors GraphQL • Cannot cache at the network level • Queries/mutations not as precise • Hard to infer errors programmatically
Option 1: Add a /graphql endpoint and implement the API from scratch • Option 2: Have a GraphQL server act as a data proxy to other REST APIs ◦ Easier, but slight performance penalty ◦ Cache as much as possible to mitigate performance hits
a query language • GraphQL is a good alternative, not REST 2.0 • If you’re happy with REST, no reason to change. • If you’re have vastly different clients that require data in different combinations, GraphQL might be right for you. • Or use both, if you could benefit from both approaches a lot.