-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp-sync.config.ts
95 lines (92 loc) · 2.49 KB
/
app-sync.config.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
89
90
91
92
93
94
95
import { DbTable } from '@src/enums/db-table';
/**
* AppSync is power by the "serverless-appsync-plugin" plugin.
* The following config goes into the root section of the
* `serverless.ts` file instead of the `Resources` section.
*/
export const appSyncConfig = {
appSync: {
name: '${self:provider.stage}-appsync-api',
logging: {
enabled: true,
level: 'ALL',
},
authentication: {
type: 'API_KEY',
},
apiKeys: ['appsync_api_key'],
additionalAuthentications: [
{
type: 'AMAZON_COGNITO_USER_POOLS',
config: { userPoolId: { Ref: 'AppUserPool' } },
},
],
schema: 'schema.graphql',
dataSources: {
...(() => {
const res = {};
// create a data source config for each DynamoDB table
Object.values(DbTable).forEach((tableName: string) => {
res[`${tableName}TableDS`] = {
type: 'AMAZON_DYNAMODB',
description: `${tableName} table`,
config: {
tableName: '${self:provider.stage}-' + tableName,
},
};
});
return res;
})(),
lambda: {
type: 'AWS_LAMBDA',
config: {
function: {
timeout: 30,
handler:
'src/modules/appsync/functions/lambda-resolver/handler.main',
},
},
},
},
resolvers: {
// 'Query.test': {
// kind: 'UNIT',
// dataSource: `${DbTable.Users}TableDS`,
// code: 'src/modules/user/resolvers/lambda.ts',
// },
'Query.getUser': {
functions: [
{
dataSource: `${DbTable.Users}TableDS`,
code: 'src/modules/user/resolvers/get-user.ts',
},
],
},
'Query.users': {
functions: [
{
dataSource: `${DbTable.Users}TableDS`,
code: 'src/modules/user/resolvers/users.ts',
},
],
// kind: 'UNIT',
// dataSource: `${DbTable.Users}TableDS`,
// code: 'src/modules/user/resolvers/users.ts',
},
},
pipelineFunctions: {
// getUser: {
// dataSource: `${DbTable.Users}TableDS`,
// code: 'src/modules/user/resolvers/get-user.ts',
// },
// users: {
// dataSource: `${DbTable.Users}TableDS`,
// code: 'src/modules/user/resolvers/usersa.ts',
// },
// test: {
// dataSource: 'lambda',
// code: 'src/modules/appsync/resolvers/lambda.ts',
// },
},
},
};