import { GraphQLClient, gql } from 'graphql-request';
const API_URL = 'https://transactional-graph.staging.fluzapp.com/api/v1/graphql';
const GET_MERCHANTS = gql`
query getMerchants($name: String, $paginate: OffsetInput) {
getMerchants(name: $name, paginate: $paginate) {
merchantId
name
slug
offers {
offerId
type
offerRates {
maxUserRewardValue
denominations
}
stockInfo {
... on StockInfoVariableType {
__typename
description
maxDenomination
minDenomination
}
... on StockInfoFixedType {
__typename
denomination
availableStock
}
}
}
}
}
`;
const client = new GraphQLClient(API_URL, {
headers: {
Authorization: `Bearer <USER_ACCESS_TOKEN>`,
'Content-Type': 'application/json',
},
});
const res = await client.request(GET_MERCHANTS, {
name: null,
paginate: { limit: 20, offset: 0 },
});
console.log(JSON.stringify(res, null, 2));