Configure the client
The getSDK gives you an SDK client for your GraphQL API
import { GraphQLClient } from "graphql-request";
import { getSdk } from "../graphqlSDKGenerator/graphqlSDKGenerator";
const initializeSDK = () => {
const client = new GraphQLClient(
"https://your-end-point/",
{
headers: {
Authorization: 'Bearer xxx',
},
}
);
return getSdk(client);
};
const main = async () => {
const sdkInstance = initializeSDK();
};
main();
Custom logger
We can pass a custom function which can be used to log the output and help in debugging. You can check live example here.
Pass dynamic headers at runtime
You can pass a function to the headers field to pull the headers at query time, this way you can make requests if user changes during the session.
Last updated