apps/bot: add function getClientWithToken

This commit is contained in:
vchikalkin 2024-12-23 14:34:57 +03:00
parent 1d4584bd6f
commit 5b14a1a75a
2 changed files with 8 additions and 4 deletions

View File

@ -1,10 +1,8 @@
import { createApolloClient } from '../apollo/client';
import { getToken } from '../utils/jwt';
import { getClientWithToken } from '../apollo/client';
import * as GQL from '@repo/graphql/types';
export async function createCustomer(variables: GQL.CreateCustomerMutationVariables) {
const token = await getToken();
const { mutate } = createApolloClient({ token });
const { mutate } = await getClientWithToken();
return mutate({
mutation: GQL.CreateCustomerDocument,

View File

@ -1,4 +1,5 @@
import { env as environment } from '../config/env';
import { getToken } from '../utils/jwt';
import { ApolloClient, InMemoryCache } from '@apollo/client/core';
type Parameters_ = { token: null | string | undefined };
@ -14,3 +15,8 @@ export function createApolloClient(parameters?: Parameters_) {
uri: environment.URL_GRAPHQL,
});
}
export async function getClientWithToken() {
const token = await getToken();
return createApolloClient({ token });
}