With your GraphQL server built, it's now time to set up GraphQL on the client side. Very broadly, a client is just an application that communicates with a server. Due to the flexibility of GraphQL, there's no prescription for how to build a client. All you really need to send queries and mutations is the ability to send an HTTP request. Once the service responds with some data, you can use it in your client no matter what that client is.
The following samples are in CodeSandbox. You will find the code in the src/index.js file for each sample. Be sure to expand the CodeSandbox console to see the results. Also, be sure to
- Fetch Client - console
- Fetch Client - browser
- GraphQL Request - query
- GraphQL Request - mutation
- GraphQL Request - app
This folder contains the server and the client for Chapter 6. Run the server then either run the client project or view it on CodeSandbox.
Be sure to add your GitHub CLIENT_ID to the .env file:
REACT_APP_CLIENT_ID=<YOUR_ID_HERE>
- Apollo Client Docs: The GraphQL client developed by Meteor Development Group
- create-react-app: A tool to create React applications with no build configuration