Skip to content

urbancvek/axioql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

axioql

GraphQL client that uses axios under the hood.

Installation

Use your usual package manager.

yarn add axioql

Usage

import AxioQL from 'axioql';

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

// If you have to authenticate use this method to set the header
AxioQL.setAuthHeader('Bearer #sometoken#');

// 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 AxioQL.request({ query: someQuery, variables: someVariables });

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published