blob: 1e7d1298a6cb91197bb9ef261f606c9ce2a00d39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import { type ExecutionResult, graphql as executeGraphql } from 'graphql';
import { HttpResponse, graphql } from 'msw';
import type { ThematicResponse } from '../../../../src/services/graphql';
import { wpThematicsFixture } from '../../../fixtures';
import { schema } from '../../schema';
export const thematicHandler = graphql.query<
ThematicResponse,
Record<'slug', string>
>('Thematic', async ({ query, variables }) => {
const { data, errors } = (await executeGraphql({
schema,
source: query,
variableValues: variables,
rootValue: {
thematic: wpThematicsFixture.find(
(wpThematic) => wpThematic.slug === variables.slug
),
},
})) as ExecutionResult<ThematicResponse>;
return HttpResponse.json({ data, errors });
});
|