module with gqhl queries
You�ll need to have Node >= 6 on your local development machine (but it�s not required on the server).
To add module to you project, run a single command:
npm install team-client-lib
or if you are using yarn
yarn add team-client-lib
Create file in your project with content: apiService.js
import mainService from 'team-client-lib';
import {makeRequest, mutate} from '$CHANGE_PATH';
export const {
clientService,
expenseService,
expenseTypeService,
leaveService,
leaveTypeService,
projectService,
departmentActions,
customerService,
locationService,
feedService,
notificationService,
pricingService,
labelService,
taskAssignmentService,
taskReportTimeService,
taskService,
timerService,
staffService,
userService
} = mainService(makeRequest, mutate);
You need to change path to makeRequest and mutate functions, This function must look like:
const client = new ApolloClient({
...
});
export const makeRequest = client.query;
export const mutate = client.mutate;
P.S. you can also add wrapper for you functions, for example:
export const makeRequest = (queryObject) => {
//Simple logger
console.log(queryObject);
return client.query(queryObject)
};
###Usage So then you can use this services:
import {clientService} from './apiService.js'
const getClients = _ => {
clientService.fetchClients().then(({data, error, errors})=>{
});
};