%%
date:: [[2022-09-30]], [[2023-07-13]]
%%
# [[GraphQL]]
[site](https://graphql.org/)
GraphQL is a query language for [[API]]s. Its strength against [[REST]] is that it is primarily used for retrieving elements rather than structuring web services. [^coredna]
With GraphQL, queries are written as a JSON string of objects rather than a text one. [^graphql]
![[When and Why to Use GraphQL#^graphqlarch]] [^graphql]
## Features of GraphQL
### Simplicity
Unlike REST, GraphQL does not typically require a complicated syntax of endpoints or different [[HTTP Methods]]. This minimalization of endpoints improves [[Respect Levels of Abstraction|Abstraction]] by focusing on objects retrieved.
## Uses of GraphQL
### Aggregation of multiple data sources
GraphQL is particularly useful in unifying different services under a single API.
### Create a [[Proxy]]
When used between the client and an API, GraphQL can be used as a proxy.
### Simplify complex API
GraphQL can provide a more intuitive API to interact with a service that has a complex structure of endpoints.
## Creating a GraphQL API
You can manually create a GraphQL API, but below are tools that make this process significantly easier.
### [[Hasura]]
[^graphql]: Lombard, J. (2018). _When and why to use GraphQL_. Design Patterns. Retrieved from https://medium.com/@JeffLombardJr/when-and-why-to-use-graphql-24f6bce4839d . [[When and Why to Use GraphQL|My highlights]].
[^coredna]: Mason, J. (2021). _What is GraphQL? (And is it really better than REST)_. Retrieved from https://www.coredna.com/blogs/what-is-graphql .