Invoking GraphQL APIs using axios

— — — — — — —

Calling a Query:

let args={user_id:”123"}
const userQuery = `query{user(id:”${args.user_id}”){id,bonus_point}}`;

let response = await axios({ url: userServiceUrl, method: ‘post’, data: { query: userQuery } });

Calling a Mutation:

let args={user_id:”123"}
const edit = `mutation{editBonus(id:”${args.user_id}”,bonus_point:${-args.room_bonus_points}){id,bonus_point}}`;

let userRes = await axios({ url: userServiceUrl, method: ‘post’, data: { query: edit } });

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store