Skip to main content

GraphQL Libraries

Although it is possible to make GraphQL requests by constructing your own requests as a string and sending them to the URL of the API, we recommend using one of the open source GraphQL libraries. Here's a brief list of commonly used ones

Apollo

Apollo Client is a comprehensive state management library for JavaScript. It enables you to manage both local and remote data with GraphQL. Use it to fetch, cache, and modify application data, all while automatically updating your UI.

Given how much Apollo can do, using it for just GraphQL calls might be overkill if all you want is one or two calls.

[https://www.apollographql.com/docs/react]

Axios

Axios is an HTTP client library for JavaScript. If you're building an app with React, Vue, or Angular, it's useful to use a GraphQL client library like Apollo Client, but if you just need to make one GraphQL call, for example from a Node. js script, you can use any library you want.

[https://www.npmjs.com/package/axios]

Amplify

Amazon's front and backend library supports authentication for and calls to and from GraphQL. You can use the Cognito authentication directly as we do in the NodeJS example with the following library:

https://www.npmjs.com/package/@aws-sdk/credential-providers [https://www.npmjs.com/package/aws-amplify](AWS Amplify) [https://docs.amplify.aws/gen1/javascript/build-a-backend/restapi/fetch-data/]

Fetch

You can construct your project around the basic fetch command. The following tutorial shows some interesting comparisons to REST and a look at the Star Wars GraphQL sample API.

[https://dev.to/atherosai/using-fetch-api-for-executing-graphql-queries-and-mutations-n3f]

info

You should check the browser support here for your project [https://caniuse.com/fetch]

In NodeJS fetch is an additional library, you can find it here: [https://www.npmjs.com/package/node-fetch]