@@ -7,8 +7,7 @@ import { isAppSyncGraphQLEvent } from './utils.js';
7
7
/**
8
8
* Resolver for AWS AppSync GraphQL APIs.
9
9
*
10
- * This resolver is designed to handle the `onQuery` and `onMutation` events
11
- * from AWS AppSync GraphQL APIs. It allows you to register handlers for these events
10
+ * This resolver is designed to handle GraphQL events from AWS AppSync GraphQL APIs. It allows you to register handlers for these events
12
11
* and route them to the appropriate functions based on the event's field & type.
13
12
*
14
13
* @example
@@ -17,13 +16,16 @@ import { isAppSyncGraphQLEvent } from './utils.js';
17
16
*
18
17
* const app = new AppSyncGraphQLResolver();
19
18
*
20
- * app.onQuery('getPost', async ({ id }) => {
19
+ * app.resolver( async ({ id }) => {
21
20
* // your business logic here
22
21
* return {
23
22
* id,
24
23
* title: 'Post Title',
25
24
* content: 'Post Content',
26
25
* };
26
+ * }, {
27
+ * fieldName: 'getPost',
28
+ * typeName: 'Query'
27
29
* });
28
30
*
29
31
* export const handler = async (event, context) =>
@@ -40,13 +42,16 @@ export class AppSyncGraphQLResolver extends Router {
40
42
*
41
43
* const app = new AppSyncGraphQLResolver();
42
44
*
43
- * app.onQuery('getPost', async ({ id }) => {
45
+ * app.resolver( async ({ id }) => {
44
46
* // your business logic here
45
47
* return {
46
48
* id,
47
49
* title: 'Post Title',
48
50
* content: 'Post Content',
49
51
* };
52
+ * }, {
53
+ * fieldName: 'getPost',
54
+ * typeName: 'Query'
50
55
* });
51
56
*
52
57
* export const handler = async (event, context) =>
@@ -62,7 +67,7 @@ export class AppSyncGraphQLResolver extends Router {
62
67
* const app = new AppSyncGraphQLResolver();
63
68
*
64
69
* class Lambda {
65
- * @app .onQuery( 'getPost')
70
+ * @app .resolver({ fieldName: 'getPost', typeName: 'Query' } )
66
71
* async handleGetPost({ id }) {
67
72
* // your business logic here
68
73
* return {
0 commit comments