diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-12-06 18:20:54 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-12-07 19:12:11 +0100 |
| commit | b8eb008dd5927fb736e56699637f5f8549965eae (patch) | |
| tree | 648274babea3d3d09ed3e0f5f1fef013f94158fb /src/utils/helpers | |
| parent | 802285872a2c57e7a5e130f32a2b45497d7687f1 (diff) | |
refactor(hooks): replace useGithubApi with useGithubRepoMeta
* use GraphQL API instead of REST (the inconvenient however is that we
now need an authorization token...)
* move fetcher in services
* add tests
* mock response using MSW
Diffstat (limited to 'src/utils/helpers')
| -rw-r--r-- | src/utils/helpers/graphql.ts | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/utils/helpers/graphql.ts b/src/utils/helpers/graphql.ts index e07b151..2d78e00 100644 --- a/src/utils/helpers/graphql.ts +++ b/src/utils/helpers/graphql.ts @@ -20,6 +20,7 @@ type GraphQLResponse<T extends GraphQLData<unknown>> = { }; export type FetchGraphQLConfig = { + headers?: HeadersInit; query: string; url: string; variables?: Record<string, unknown>; @@ -35,6 +36,7 @@ export type FetchGraphQLConfig = { export const fetchGraphQL = async < T extends GraphQLData<unknown> = GraphQLData<unknown>, >({ + headers, query, url, variables, @@ -42,6 +44,7 @@ export const fetchGraphQL = async < const response = await fetch(url, { method: 'POST', headers: { + ...headers, 'content-type': 'application/json;charset=UTF-8', }, body: JSON.stringify({ |
