generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 176
feat(event-handler): Add includeRouter
support to AppSync GraphQL resolver
#4457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
svozza
merged 28 commits into
aws-powertools:main
from
arnabrahman:4131-graphql-includerouter
Oct 13, 2025
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d4e4232
feat: enhance error handling with detailed logging and handler merging
arnabrahman 725b67d
feat: improve resolver registration with dedicated warning method and…
arnabrahman dcbc532
feat: add method to merge resolver registries from another router
arnabrahman c79e4a3
feat: add `includeRouter` method to merge route registries into AppSy…
arnabrahman 32d713b
test: `includeRouter` function tests
arnabrahman 1dcfb69
feat: export `Router` from Router.js in AppSync GraphQL index
arnabrahman 4d858fd
feat: add shared context support to AppSync resolver and handler types
arnabrahman 7a96f86
test: tests for `includeRouter` method and context sharing in AppSync…
arnabrahman 607ed4e
test: add tests for sharedContext handling in batch resolvers
arnabrahman 7227f94
refactor: update includeRouter method to accept multiple routers and …
arnabrahman da0368b
refactor: streamline logging in includeRouter method for clarity
arnabrahman 1f2bb0c
refactor: rename context to sharedContext for clarity and consistency
arnabrahman 46bb220
doc: enhance sharedContext documentation and update example usage in …
arnabrahman 14f601f
refactor: clear shared context after processing to prevent data leakage
arnabrahman fcd3847
refactor: remove debug logging during registry merging for cleaner ou…
arnabrahman ecc1f1d
doc: `includeRouter` & `appendContext` method doc
arnabrahman 450ed66
refactor: standardize router naming and improve type annotations in e…
arnabrahman 28645ca
refactor: remove debug logging from registry merging for cleaner output
arnabrahman 3147d3e
refactor: improve clarity in comments and streamline router example code
arnabrahman 364faca
refactor: extract sharedContext empty check in a method
arnabrahman f7b8492
test: update sharedContext in AppSyncGraphQLResolver test for consist…
arnabrahman 2b40997
refactor: remove unnecessary await from error handling in resolver me…
arnabrahman aef50b9
refactor: remove sharedContext from AppSyncGraphQLResolver and relate…
arnabrahman b2bbf20
doc: remove appendContext and related router examples for clarity
arnabrahman 55c125d
refactor: simplify event and context handling in resolver methods
arnabrahman 326587e
refactor: remove unnecessary blank line in AppSyncGraphQLResolver
arnabrahman 0a20b2e
doc: add note about handler precedence and conflict warnings for `inc…
arnabrahman f911c81
Merge branch 'main' into 4131-graphql-includerouter
svozza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
examples/snippets/event-handler/appsync-graphql/postRouter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Router } from '@aws-lambda-powertools/event-handler/appsync-graphql'; | ||
|
||
const postRouter = new Router(); | ||
|
||
postRouter.onQuery('getPosts', async () => { | ||
return [{ id: 1, title: 'First post', content: 'Hello world!' }]; | ||
}); | ||
|
||
postRouter.onMutation('createPost', async ({ title, content }) => { | ||
return { | ||
id: Date.now(), | ||
title, | ||
content, | ||
createdAt: new Date().toISOString(), | ||
}; | ||
}); | ||
|
||
export { postRouter }; |
11 changes: 11 additions & 0 deletions
11
examples/snippets/event-handler/appsync-graphql/splitRouter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { AppSyncGraphQLResolver } from '@aws-lambda-powertools/event-handler/appsync-graphql'; | ||
import type { Context } from 'aws-lambda'; | ||
import { postRouter } from './postRouter'; | ||
import { userRouter } from './userRouter'; | ||
|
||
const app = new AppSyncGraphQLResolver(); | ||
|
||
app.includeRouter([postRouter, userRouter]); | ||
|
||
export const handler = async (event: unknown, context: Context) => | ||
app.resolve(event, context); |
9 changes: 9 additions & 0 deletions
9
examples/snippets/event-handler/appsync-graphql/userRouter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Router } from '@aws-lambda-powertools/event-handler/appsync-graphql'; | ||
|
||
const userRouter = new Router(); | ||
|
||
userRouter.onQuery('getUsers', async () => { | ||
return [{ id: 1, name: 'John Doe', email: 'john@example.com' }]; | ||
}); | ||
|
||
export { userRouter }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.