From b8eb008dd5927fb736e56699637f5f8549965eae Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 6 Dec 2023 18:20:54 +0100 Subject: 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 --- src/utils/helpers/graphql.ts | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/utils/helpers/graphql.ts') 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> = { }; export type FetchGraphQLConfig = { + headers?: HeadersInit; query: string; url: string; variables?: Record; @@ -35,6 +36,7 @@ export type FetchGraphQLConfig = { export const fetchGraphQL = async < T extends GraphQLData = GraphQLData, >({ + 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({ -- cgit v1.2.3