This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
website/src/libs/graphql/createClient.ts
2021-04-14 20:11:35 +02:00

14 lines
389 B
TypeScript

import { GraphQLClient } from 'graphql-request';
const getApiURI = () => {
return (
(typeof window === 'undefined' && process.env.BUILDING_PROCESS !== 'true'
? process.env.SERVER_API_URI
: process.env.NEXT_PUBLIC_API_URI) ?? 'http://localhost:8080/graphql'
);
};
export const createClient = (uri = getApiURI()): GraphQLClient => {
return new GraphQLClient(uri);
};