Socket
Book a DemoInstallSign in
Socket

fetch-graphql

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-graphql

Super simple GraphQL fetch client, with built in error handling

1.1.0
latest
Source
npmnpm
Version published
Weekly downloads
17
-29.17%
Maintainers
2
Weekly downloads
 
Created
Source

fetch-graphql

Super simple GraphQL fetch client, with built in error handling.

Installing

npm add fetch-graphql

Usage

import fetchGraphQL from 'fetch-graphql'

const query = `
  query ListUsers($filter: UserFilter) {
    users(filter: $filter) {
      id

      firstName
      lastName
    }
  }
`

const variables = {
  filter: {
    firstName: 'Safaiyeh'
  }
}

const data = await fetchGraphQL(
  'https://yourAPI.com/graphql',
  query,
  variables,
  { 'header1': 'headerValue1', ...headers }
)

console.log(data.users)

Error handling

If the GraphQL response contains errors, the returned Promise will reject with a fully populated error. If there was multiple errors, it rejects with an AggregateError that contains all the errors.

AWS AppSync

Pass your API Key to x-api-key header

const headers = {
  'x-api-key': '<AWS KEY HERE>'
}

FAQs

Package last updated on 16 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.