@@ -7,8 +7,7 @@ import { isAppSyncGraphQLEvent } from './utils.js';
77/**
88 * Resolver for AWS AppSync GraphQL APIs.
99 *
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
1211 * and route them to the appropriate functions based on the event's field & type.
1312 *
1413 * @example
@@ -17,13 +16,16 @@ import { isAppSyncGraphQLEvent } from './utils.js';
1716 *
1817 * const app = new AppSyncGraphQLResolver();
1918 *
20- * app.onQuery('getPost', async ({ id }) => {
19+ * app.resolver( async ({ id }) => {
2120 * // your business logic here
2221 * return {
2322 * id,
2423 * title: 'Post Title',
2524 * content: 'Post Content',
2625 * };
26+ * }, {
27+ * fieldName: 'getPost',
28+ * typeName: 'Query'
2729 * });
2830 *
2931 * export const handler = async (event, context) =>
@@ -40,13 +42,16 @@ export class AppSyncGraphQLResolver extends Router {
4042 *
4143 * const app = new AppSyncGraphQLResolver();
4244 *
43- * app.onQuery('getPost', async ({ id }) => {
45+ * app.resolver( async ({ id }) => {
4446 * // your business logic here
4547 * return {
4648 * id,
4749 * title: 'Post Title',
4850 * content: 'Post Content',
4951 * };
52+ * }, {
53+ * fieldName: 'getPost',
54+ * typeName: 'Query'
5055 * });
5156 *
5257 * export const handler = async (event, context) =>
@@ -62,7 +67,7 @@ export class AppSyncGraphQLResolver extends Router {
6267 * const app = new AppSyncGraphQLResolver();
6368 *
6469 * class Lambda {
65- * @app .onQuery( 'getPost')
70+ * @app .resolver({ fieldName: 'getPost', typeName: 'Query' } )
6671 * async handleGetPost({ id }) {
6772 * // your business logic here
6873 * return {
0 commit comments