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 --- tests/msw/handlers/posts/posts-count.handler.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tests/msw/handlers/posts/posts-count.handler.ts') diff --git a/tests/msw/handlers/posts/posts-count.handler.ts b/tests/msw/handlers/posts/posts-count.handler.ts index 95fa105..a4425a5 100644 --- a/tests/msw/handlers/posts/posts-count.handler.ts +++ b/tests/msw/handlers/posts/posts-count.handler.ts @@ -1,12 +1,13 @@ -import { type ExecutionResult, graphql as executeGraphql } from 'graphql'; -import { HttpResponse, graphql } from 'msw'; +import { type ExecutionResult, graphql } from 'graphql'; +import { HttpResponse } from 'msw'; import type { PostsCountResponse } from '../../../../src/services/graphql'; import type { GraphQLPostWhere } from '../../../../src/types'; import { wpPostsFixture } from '../../../fixtures'; import { getConnection } from '../../../utils/graphql'; +import { wordpressAPI } from '../../instances'; import { schema } from '../../schema'; -export const postsCountHandler = graphql.query< +export const postsCountHandler = wordpressAPI.query< PostsCountResponse, GraphQLPostWhere >('PostsCount', async ({ query, variables }) => { @@ -15,7 +16,7 @@ export const postsCountHandler = graphql.query< if (isError) return HttpResponse.json({ data: { posts: null } }); - const { data, errors } = (await executeGraphql({ + const { data, errors } = (await graphql({ schema, source: query, variableValues: variables, -- cgit v1.2.3