-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathcodegen.ts
88 lines (80 loc) · 2.21 KB
/
codegen.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import type { CodegenConfig } from '@graphql-codegen/cli';
// import Constants from 'expo-constants';
const API_URL = 'https://www.minds.com/';
const MAIN_API_URI = `${API_URL}api/graphql`;
// const MAIN_API_URI =
// 'https://feat-gift-card-txs-m4165.oke.minds.io/api/graphql';
const STRAPI_API_URI = 'https://cms.minds.com/graphql';
// use this for sandbox
// const STRAPI_API_URI = 'https://cms.oke.minds.io/graphql';
const defaultHeaders = {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache, no-store, must-revalidate',
Pragma: 'no-cache',
'no-cache': '1',
};
const queryPlugins = [
'typescript',
'typescript-operations',
'typescript-react-query',
];
const strapi_schema = {
schema: { [STRAPI_API_URI]: { headers: defaultHeaders } },
};
const api_schema = {
schema: {
[MAIN_API_URI]: {
headers: { ...defaultHeaders, Cookie: 'staging=1' },
},
},
};
/**
* GraphQL Codegen configuration.
*/
const config: CodegenConfig = {
overwrite: true,
ignoreNoDocuments: true,
generates: {
'./src/graphql/strapi.ts': {
// use this if introspection fails and comment ...strapi_schema
// schema: './gql-schemas/strapi.schema.json',
...strapi_schema,
documents: ['src/**/*.strapi.graphql'],
plugins: queryPlugins,
config: {
namedClient: 'strapi',
fetcher: {
func: '~/common/services/strapi.service#gqlFetcher',
isReactHook: false,
},
},
},
'./src/graphql/api.ts': {
// use this if introspection fails and comment ...api_schema
// schema: './gql-schemas/api.schema.json',
...api_schema,
documents: ['src/**/*.api.graphql'],
plugins: queryPlugins,
config: {
namedClient: 'default',
fetcher: {
func: '~/common/services/gqlFetcher#gqlFetcher',
isReactHook: false,
},
addInfiniteQuery: true,
exposeQueryKeys: true,
exposeFetcher: true,
},
},
// INTROSPECTION
'./gql-schemas/api.schema.json': {
...api_schema,
plugins: ['introspection'],
},
'./gql-schemas/strapi.schema.json': {
...strapi_schema,
plugins: ['introspection'],
},
},
};
export default config;