diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-27 19:38:32 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-27 20:06:56 +0100 |
| commit | ff79add1d59375817a10331a35458cca3c419cfe (patch) | |
| tree | 5e678e2c3cd43ace5cb7fd27a22f6e8403ccd211 /tests/msw/schema/index.ts | |
| parent | f111685c5886f3e77edfd3621c98d8ac1b9bcce4 (diff) | |
test: add MSW to intercept GraphQL requests
Diffstat (limited to 'tests/msw/schema/index.ts')
| -rw-r--r-- | tests/msw/schema/index.ts | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/msw/schema/index.ts b/tests/msw/schema/index.ts new file mode 100644 index 0000000..3763616 --- /dev/null +++ b/tests/msw/schema/index.ts @@ -0,0 +1,38 @@ +import { addResolversToSchema } from '@graphql-tools/schema'; +import type { IResolvers } from '@graphql-tools/utils'; +import { buildSchema } from 'graphql'; +import { types } from './types'; + +/* eslint-disable camelcase -- We have no control on WP GraphQL types */ +const resolvers: IResolvers = { + Post_Acfposts_PostsInThematic: { + __resolveType() { + return 'Thematic'; + }, + }, + Post_Acfposts_PostsInTopic: { + __resolveType() { + return 'Topic'; + }, + }, + Thematic_Acfthematics_PostsInThematic: { + __resolveType() { + return 'Post'; + }, + }, + Topic_Acftopics_PostsInTopic: { + __resolveType() { + return 'Post'; + }, + }, +}; +/* eslint-enable camelcase */ + +// cSpell:ignore Acfposts Acfthematics Acftopics camelcase + +const schemaFromTypes = buildSchema(types.join('\n')); + +export const schema = addResolversToSchema({ + schema: schemaFromTypes, + resolvers, +}); |
