Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 783 Bytes

File metadata and controls

42 lines (33 loc) · 783 Bytes

GraphQLFetch

A GraphQL fetch library in Javasript

Installation

First, install the library:

npm i graphql-api-fetch

Usage

import { GraphQLFetch } from 'graphql-api-fetch';

const QUERY = `
      query ($keyword: String){
        users(keyword: $keyword){
            users{
                id
                email
                firstName
                lastName
            }
        }
      }`;

GraphQLFetch({
            query: QUERY,
            variables: { keyword } // optional
        }).then((res) => {
            if (res.errors) {
                errors = res.errors.map((error) => error.message);
            }
            else usersData = res.data.users.users;
        });

Contributers