Skip to content

Commit c615cf0

Browse files
committed
convert entity headers from static to dynamic
1 parent 8126c95 commit c615cf0

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

config/site.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,3 @@ export const siteConfig: SiteConfig = {
99

1010
export const locales = ['en', 'hi'];
1111

12-
export const gqlConfig = {
13-
url: `${process.env.BACKEND_GRAPHQL_URL}`,
14-
headers: {
15-
organization: '1',
16-
},
17-
};

lib/api.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,19 @@ import { QueryClient } from '@tanstack/react-query';
44
import { request } from 'graphql-request';
55
import { getSession } from 'next-auth/react';
66

7-
import { gqlConfig } from '@/config/site';
8-
97
// create a wrapper function for graphql-request
108
// that will be used by react-query
119

1210
export async function GraphQL<TResult, TVariables>(
1311
document: TypedDocumentNode<TResult, TVariables>,
12+
entityHeaders: Record<string, string> = {},
1413
...[variables]: TVariables extends Record<string, never> ? [] : [TVariables]
1514
) {
1615
const session = await getSession();
1716

1817
const headers = {
19-
...gqlConfig.headers,
2018
...(session ? { Authorization: session?.access_token } : {}),
19+
...entityHeaders,
2120
};
2221

2322
const data = await request(

0 commit comments

Comments
 (0)