aboutsummaryrefslogtreecommitdiffstats
path: root/tests/msw/schema/index.ts
blob: c818d50e58e4b98d654de48ee2fbb9183e098717 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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,
});

export const githubSchema = buildSchema(`
scalar DateTime

type Repository {
  createdAt: DateTime!
  stargazerCount: Int!
  updatedAt: DateTime!
}

type Query {
  repository(
    followRenames: Boolean = true
    name: String!
    owner: String!
  ): Repository
}`);