baxioql

1.0.18 • Public • Published

baxioql

GraphQL client that uses axios under the hood.

Installation

Use your usual package manager.

npm install baxioql

Usage

import baxioql from 'baxioql';

// Set the endpoint that will be used for all your GraphQL requests
baxioql.setQLEndpoint('https://graphql.server.com/graphql');

// If you have to authenticate use this method to set the header
baxioql.setAuthHeader('Authentication', 'token');

// Create a query
const someQuery = `query ($searchText: String!) {
  productSearch(title: $searchText) {
    id
    title
    brand
  }
}`;

// Add variables used by the query
const someVariables = {
  searchText: 'Milk',  
};

const yourAsyncMethod = async () => {
  try {
    // Fetch your data
    const response = await baxioql.request({ query: someQuery, variables: someVariables });

    console.log(response.data.data);
  } catch (error) {
    console.error(error);
  }
};

Dependents (0)

Package Sidebar

Install

npm i baxioql

Weekly Downloads

19

Version

1.0.18

License

MIT

Last publish

Collaborators

  • bcowell