Summary
We can easily create a GraphQL API with Express and the express-graphql
library. To make GraphQL HTTP requests easily, we use the graphql-request
JavaScript GraphQL client, which works in the browser. This lets us set request options such as headers, the query to make, and variables that go with the query easily.
The graphql-request
GraphQL client is used instead of a regular HTTP client to make requests to the backend from our Vue app. The graphql-request
library lets us make GraphQL HTTP requests more easily than when using a regular HTTP client. With it, we can easily pass in GraphQL queries and mutations with variables.
A GraphQL API is created with a schema that maps to resolver functions. Schemas let us define all the data types of our input and output data so that we don't have to guess which data we have to send. If we send any invalid data, then we will get an error telling us exactly what is wrong with the request. We also have to specify the data fields...