GraphQL / RESTful
The dead RESTful API && Approach to Hypermedia
minayaleon@gmail.com
RESTful is dead?
if google says it then it is true.
or not?
minayaleon@gmail.com
Why?
• Requires many requests to obtain the necessary data in a view of our
application
• If the endpoint changes then the clients fall
• The error codes 2XX, 3XX, 4XX or 5XX are not used
• It does not have a formalized type system losing the power of tools
like Swagger to document
• REST is very old 
minayaleon@gmail.com
GraphQL
• It was created by Facebook
• Is a query language for APIs and for executing queries by using a type
system you define for your data
• Use a strong typing system
• It isn't tied to any specific database or storage engine and is instead
backed by your existing code and data.
minayaleon@gmail.com
Wait, I have a gift
minayaleon@gmail.com
minayaleon@gmail.com
Bad Decisions
minayaleon@gmail.com
1 2
RequirementsTools
Know your needs
minayaleon@gmail.com
1 2
Requirements Tools
Conclusions I
• Know your needs
• Know the tools
• Choose the best tool, choose it yourself
• No more “X is dead”
minayaleon@gmail.com
2018A look at the current state of the APIs &&
Web
minayaleon@gmail.com
Contracts
minayaleon@gmail.com
https://api.lifetap.com
- Native App Lifetap
- Web Lifetap
But…
• Change the endpoint
• Add new input parameters in the endpoints
• We launch a new version
• http://api.lifetap.com/v1, http://api.lifetap.com/v2
• More and more features
minayaleon@gmail.com
Broken Contracts
minayaleon@gmail.com
What should we do?...
minayaleon@gmail.com
And when can not?
Conclusions II
• We have forgotten the most important features of the web: Evolution
• The web has survived more than 30 years
• We must create Evolvable APIs
minayaleon@gmail.com
How to create APIs
designed to evolve?
minayaleon@gmail.com
RESTful Foundation
REST
Shared
Vocabularies
Hypermedia
Evolvable APIs
minayaleon@gmail.com
The Glory of REST
Martin Fowler
Hypermedia
But, it is not new 
minayaleon@gmail.com
Your project uses hypermedia
• But it is very limited
minayaleon@gmail.com
Hypermedia - Controls
Home
• One single URL (Home)
• The APIs are navigable
Types of controls
• How does an application
navigate?
• IANA define 80 types of links
• We can create more types
minayaleon@gmail.com
Hypermedia - IANA
Hypermedia
http://api.lifetap.com
The clients now can navigate
they don't need to know
others URLs
HATEOAS
minayaleon@gmail.com
Hypermedia
minayaleon@gmail.com
HAL
(Hypertext Application Language)
Hypermedia - Actions
minayaleon@gmail.com
Hypermedia – Actions
minayaleon@gmail.com
Siren
Specification for
representing entities
Shared Vocabularies
it is not new, either 
minayaleon@gmail.com
Shared Vocabularies
• Types and Properties
• screma.org has defined 600 types and 870 properties.
• We can create more types and properties
• The data models should not be exposed, they must be normalized.
• The clients should know the types and properties
minayaleon@gmail.com
Shared Vocabularies
minayaleon@gmail.com
Shared Vocabularies (Swagger &
OpenAPI)
minayaleon@gmail.com
Use Case: Convert MOV to MP4
API
192.168.5.67
Process
195.168.5.56
• Request
• Queries
• CRUD
• and more…
• Jobs
• Sync DB
• Video Convert
• CDN
https://proc.lifetap.com/upload-videohttps://api.lifetap.com/upload-video
SSH
1
2
minayaleon@gmail.com
RESTful
Real Application
minayaleon@gmail.com
minayaleon@gmail.com
Use nouns, no verbs.
Resource Name
• When we write code, we name the
methods with verbs that describe
their functionality. For example,
get_users or getUsers. This is fine in
the code. But it's also common in
URLs and it's not a good practice
• keep it simple
• The important is focus on the nouns
that describe each resource. Now, to
operate on our resource we will use
HTTP verbs.
Relations
• What happens when our
resources are related?
/getUsers, /getUserById, /createUser, /editUser
/users, /users/:id, /products, /orders
/orders/:id/products
/projects/:id/segments/:id/qualifications
minayaleon@gmail.com
Methods
HTTP Verbs CRUD Action
GET Read Use GET requests to retrieve resource representation/information
only
POST Create Use POST APIs to create new resources
PUT Update/Replace Use PUT APIs to update existing resource
PATCH Update/Modify HTTP PATCH requests are to make partial update on a resource
DELETE Delete As the name applies, DELETE APIs are used to delete resources
minayaleon@gmail.com
Errors Code
Code Description
200 OK
400 Bad Request
401 Unauthorized
404 Resource not found
500 Internal Server Error
minayaleon@gmail.com
Sources
• https://martinfowler.com/articles/richardsonMaturityModel.html
• https://swagger.io/specification/
• https://www.iana.org/assignments/link-relations/link-relations.xhtml
• https://schema.org
• http://stateless.co/hal_specification.html
• http://hyperschema.org/mediatypes/siren
• https://apigility.org/documentation/api-primer/halprimer
• https://platzi.com/blog/como-crear-apis/
minayaleon@gmail.com
minayaleon@gmail.com
https://www.linkedin.com/in/minayaleon
https://github.com/minayaleon
http://www.zend-rad.com
http://www.codepso.com
Thank You
minayaleon@gmail.com
Juan Minaya Leon

GraphQL or RESTful