apps/bot: add function getClientWithToken
This commit is contained in:
parent
1d4584bd6f
commit
5b14a1a75a
@ -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,
|
||||
|
||||
@ -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 });
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user