npm.io
1.0.2 • Published 4 years ago

graphql-api-fetch

Licence
MIT
Version
1.0.2
Deps
1
Size
20 kB
Vulns
23
Weekly
0
Stars
1

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

Keywords