Author: Yumicode
Developing a GraphQL API during the training at O'clock in Data & API specialization with @Benjamin Nougadère
We will be using Apollo Server Express to connect GraphQL to the Express server for its usage.
GraphQL (Graph Query Language) is a query language and execution environment that is open source.
It offers an alternative to RESTful APIs, which are an architecture that allows querying the URI (Uniform Resource Identifier) of a resource, returning a response with the body
mostly formatted as JSON.
In both cases, and as is the case for most situations, the HTTP transfer protocol is used with its methods GET, HEAD, POST, PUT, PATCH, DELETE, CONNECT, OPTIONS, and TRACE.
With GraphQL, there will only be a single URI used, and the method will be POST
. Everything is centralized, and with Apollo Server Express, we will optimize the queries and, by extension, the performance of our API.
For this project, we will be using the Express server and connecting the Apollo Server to be able to use GraphQL.
npm init
And the dependencies we will need are as follows:
npm i express pg dotenv apollo-server-express apollo-datasource-rest dataloader datasource-sql graphql-scalars
Details here
Various sources: