diff options
Diffstat (limited to 'src/services/graphql/api.ts')
| -rw-r--r-- | src/services/graphql/api.ts | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/src/services/graphql/api.ts b/src/services/graphql/api.ts deleted file mode 100644 index a5be026..0000000 --- a/src/services/graphql/api.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { RequestType, VariablesType } from '@ts/types/app'; -import { settings } from '@utils/config'; -import { GraphQLClient } from 'graphql-request'; - -export const getGraphQLClient = (): GraphQLClient => { - const apiUrl = settings.api.url; - - if (!apiUrl) throw new Error('API URL not defined.'); - - return new GraphQLClient(apiUrl); -}; - -export const fetchApi = async <T extends RequestType>( - query: string, - variables: VariablesType<T> -): Promise<T> => { - const client = getGraphQLClient(); - - try { - return await client.request(query, variables); - } catch (error) { - console.error(error, undefined, 2); - process.exit(1); - } -}; |
