Skip to content

Commit 0ee00b3

Browse files
authored
Merge branch 'main' into dependabot/github_actions/aws-actions/configure-aws-credentials-4.3.1
2 parents 443976e + 5217d5e commit 0ee00b3

24 files changed

+480
-721
lines changed

examples/app/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
},
3030
"devDependencies": {
3131
"@types/aws-lambda": "^8.10.152",
32-
"@types/node": "24.1.0",
32+
"@types/node": "24.2.0",
3333
"aws-cdk-lib": "^2.208.0",
3434
"constructs": "^10.4.2",
3535
"source-map-support": "^0.5.21",
3636
"tsx": "^4.20.3",
37-
"typescript": "^5.8.3",
37+
"typescript": "^5.9.2",
3838
"vitest": "^3.0.5"
3939
},
4040
"dependencies": {
@@ -44,14 +44,14 @@
4444
"@aws-lambda-powertools/metrics": "^2.24.1",
4545
"@aws-lambda-powertools/parameters": "^2.24.1",
4646
"@aws-lambda-powertools/tracer": "^2.24.1",
47-
"@aws-sdk/client-ssm": "^3.858.0",
48-
"@aws-sdk/lib-dynamodb": "^3.858.0",
47+
"@aws-sdk/client-ssm": "^3.859.0",
48+
"@aws-sdk/lib-dynamodb": "^3.859.0",
4949
"@middy/core": "^4.7.0",
5050
"@types/aws-lambda": "^8.10.152",
51-
"@types/node": "24.1.0",
51+
"@types/node": "24.2.0",
5252
"aws-cdk": "^2.1023.0",
5353
"constructs": "^10.4.2",
5454
"esbuild": "^0.25.8",
55-
"typescript": "^5.8.3"
55+
"typescript": "^5.9.2"
5656
}
5757
}

examples/snippets/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
"@aws-lambda-powertools/parameters": "^2.24.1",
3434
"@aws-lambda-powertools/parser": "^2.24.1",
3535
"@aws-lambda-powertools/tracer": "^2.24.1",
36-
"@aws-sdk/client-appconfigdata": "^3.858.0",
37-
"@aws-sdk/client-dynamodb": "^3.858.0",
38-
"@aws-sdk/client-secrets-manager": "^3.858.0",
39-
"@aws-sdk/client-ssm": "^3.858.0",
40-
"@aws-sdk/util-dynamodb": "^3.858.0",
36+
"@aws-sdk/client-appconfigdata": "^3.859.0",
37+
"@aws-sdk/client-dynamodb": "^3.859.0",
38+
"@aws-sdk/client-secrets-manager": "^3.859.0",
39+
"@aws-sdk/client-ssm": "^3.859.0",
40+
"@aws-sdk/util-dynamodb": "^3.859.0",
4141
"@middy/core": "^4.7.0",
4242
"@redis/client": "^5.7.0",
4343
"@valkey/valkey-glide": "^2.0.1",

package-lock.json

Lines changed: 224 additions & 218 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@
5252
"devDependencies": {
5353
"@biomejs/biome": "^2.1.3",
5454
"@types/aws-lambda": "^8.10.152",
55-
"@types/node": "^24.1.0",
55+
"@types/node": "^24.2.0",
5656
"@vitest/coverage-v8": "^3.2.4",
5757
"husky": "^9.1.7",
5858
"lint-staged": "^16.1.2",
5959
"markdownlint-cli2": "^0.18.1",
6060
"middy5": "npm:@middy/core@^5.4.3",
6161
"middy6": "npm:@middy/core@^6.0.0",
62-
"typedoc": "^0.28.8",
62+
"typedoc": "^0.28.9",
6363
"typedoc-plugin-missing-exports": "^4.0.0",
64-
"typescript": "^5.8.3",
64+
"typescript": "^5.9.2",
6565
"vitest": "^3.0.9"
6666
},
6767
"lint-staged": {

packages/event-handler/src/appsync-graphql/RouteHandlerRegistry.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ class RouteHandlerRegistry {
4040
public register(
4141
options: RouteHandlerOptions<Record<string, unknown>, boolean, boolean>
4242
): void {
43-
const { fieldName, handler, typeName, throwOnError, aggregate } = options;
43+
const {
44+
fieldName,
45+
handler,
46+
typeName,
47+
throwOnError = false,
48+
aggregate = true,
49+
} = options;
4450
this.#logger.debug(`Adding resolver for field ${typeName}.${fieldName}`);
4551
const cacheKey = this.#makeKey(typeName, fieldName);
4652
if (this.resolvers.has(cacheKey)) {

packages/event-handler/src/appsync-graphql/Router.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ class Router {
531531
fieldName,
532532
handler: handler as BatchResolverHandler,
533533
typeName,
534-
aggregate: batchResolverOptions?.aggregate ?? true,
535-
throwOnError: batchResolverOptions?.throwOnError ?? false,
534+
aggregate: batchResolverOptions?.aggregate,
535+
throwOnError: batchResolverOptions?.throwOnError,
536536
});
537537
return;
538538
}
@@ -544,8 +544,8 @@ class Router {
544544
fieldName,
545545
handler: descriptor?.value,
546546
typeName,
547-
aggregate: batchResolverOptions?.aggregate ?? true,
548-
throwOnError: batchResolverOptions?.throwOnError ?? false,
547+
aggregate: batchResolverOptions?.aggregate,
548+
throwOnError: batchResolverOptions?.throwOnError,
549549
});
550550
return descriptor;
551551
};
@@ -730,8 +730,8 @@ class Router {
730730
fieldName,
731731
handler: handlerOrOptions as BatchResolverHandler,
732732
typeName: 'Query',
733-
aggregate: options?.aggregate ?? true,
734-
throwOnError: options?.throwOnError ?? false,
733+
aggregate: options?.aggregate,
734+
throwOnError: options?.throwOnError,
735735
});
736736

737737
return;
@@ -742,8 +742,8 @@ class Router {
742742
fieldName,
743743
handler: descriptor?.value,
744744
typeName: 'Query',
745-
aggregate: handlerOrOptions?.aggregate ?? true,
746-
throwOnError: handlerOrOptions?.throwOnError ?? false,
745+
aggregate: handlerOrOptions?.aggregate,
746+
throwOnError: handlerOrOptions?.throwOnError,
747747
});
748748

749749
return descriptor;
@@ -927,8 +927,8 @@ class Router {
927927
fieldName,
928928
handler: handlerOrOptions as BatchResolverHandler,
929929
typeName: 'Mutation',
930-
aggregate: options?.aggregate ?? true,
931-
throwOnError: options?.throwOnError ?? false,
930+
aggregate: options?.aggregate,
931+
throwOnError: options?.throwOnError,
932932
});
933933

934934
return;
@@ -939,8 +939,8 @@ class Router {
939939
fieldName,
940940
handler: descriptor?.value,
941941
typeName: 'Mutation',
942-
aggregate: handlerOrOptions?.aggregate ?? true,
943-
throwOnError: handlerOrOptions?.throwOnError ?? false,
942+
aggregate: handlerOrOptions?.aggregate,
943+
throwOnError: handlerOrOptions?.throwOnError,
944944
});
945945

946946
return descriptor;

packages/event-handler/tests/unit/appsync-graphql/AppSyncGraphQLResolver.test.ts

Lines changed: 78 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,11 @@ describe('Class: AppSyncGraphQLResolver', () => {
506506
setupHandler(handler);
507507

508508
if (aggregate) {
509-
app.batchResolver(handler, {
510-
fieldName: 'batchGet',
511-
typeName: 'Query',
509+
app.onBatchQuery('batchGet', handler, {
512510
aggregate: true,
513511
});
514512
} else {
515-
app.batchResolver(handler, {
516-
fieldName: 'batchGet',
517-
typeName: 'Query',
513+
app.onBatchQuery('batchGet', handler, {
518514
aggregate: false,
519515
throwOnError: true,
520516
});
@@ -596,16 +592,14 @@ describe('Class: AppSyncGraphQLResolver', () => {
596592
.mockResolvedValueOnce({ id: '1', value: 'A' })
597593
.mockRejectedValueOnce(new Error('fail'))
598594
.mockResolvedValueOnce({ id: '3', value: 'C' });
599-
app.batchResolver(handler, {
600-
fieldName: 'batchGet',
601-
typeName: 'Query',
595+
app.onBatchMutation('batchPut', handler, {
602596
aggregate: false,
603597
throwOnError: true,
604598
});
605599
const events = [
606-
onGraphqlEventFactory('batchGet', 'Query', { id: '1' }),
607-
onGraphqlEventFactory('batchGet', 'Query', { id: '2' }),
608-
onGraphqlEventFactory('batchGet', 'Query', { id: '3' }),
600+
onGraphqlEventFactory('batchPut', 'Mutation', { id: '1' }),
601+
onGraphqlEventFactory('batchPut', 'Mutation', { id: '2' }),
602+
onGraphqlEventFactory('batchPut', 'Mutation', { id: '3' }),
609603
];
610604

611605
// Act
@@ -640,4 +634,76 @@ describe('Class: AppSyncGraphQLResolver', () => {
640634
)
641635
);
642636
});
637+
638+
it.each([
639+
{
640+
throwOnError: true,
641+
description: 'throwOnError=true',
642+
},
643+
{
644+
throwOnError: false,
645+
description: 'throwOnError=false',
646+
},
647+
])(
648+
'preserves the scope when using `onBatchQuery` & `onBatchMutation` decorators when aggregate=false and $description',
649+
async ({ throwOnError }) => {
650+
// Prepare
651+
const app = new AppSyncGraphQLResolver({ logger: console });
652+
653+
class Lambda {
654+
public readonly scope = 'scoped';
655+
656+
@app.onBatchQuery('batchGet', {
657+
throwOnError,
658+
})
659+
public async handleBatchGet(
660+
events: AppSyncResolverEvent<{ id: number }>[]
661+
) {
662+
const ids = events.map((event) => event.arguments.id);
663+
return ids.map((id) => ({
664+
id,
665+
scope: this.scope,
666+
}));
667+
}
668+
669+
@app.onBatchMutation('batchPut', {
670+
throwOnError,
671+
})
672+
public async handleBatchPut(
673+
_events: AppSyncResolverEvent<{ id: number }>[]
674+
) {
675+
return [this.scope, this.scope];
676+
}
677+
678+
public async handler(event: unknown, context: Context) {
679+
return app.resolve(event, context, { scope: this });
680+
}
681+
}
682+
const lambda = new Lambda();
683+
const handler = lambda.handler.bind(lambda);
684+
685+
// Act
686+
const resultQuery = await handler(
687+
[
688+
onGraphqlEventFactory('batchGet', 'Query', { id: 1 }),
689+
onGraphqlEventFactory('batchGet', 'Query', { id: 2 }),
690+
],
691+
context
692+
);
693+
const resultMutation = await handler(
694+
[
695+
onGraphqlEventFactory('batchPut', 'Mutation', { id: 1 }),
696+
onGraphqlEventFactory('batchPut', 'Mutation', { id: 2 }),
697+
],
698+
context
699+
);
700+
701+
// Assess
702+
expect(resultQuery).toEqual([
703+
{ id: 1, scope: 'scoped' },
704+
{ id: 2, scope: 'scoped' },
705+
]);
706+
expect(resultMutation).toEqual(['scoped', 'scoped']);
707+
}
708+
);
643709
});

packages/event-handler/tests/unit/appsync-graphql/RouteHandlerRegistry.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,18 @@ describe('Class: RouteHandlerRegistry', () => {
5959
// Assess
6060
expect(registry.resolvers.size).toBe(1);
6161
expect(registry.resolvers.get('Query.getPost')).toEqual({
62+
aggregate: true,
6263
fieldName: 'getPost',
6364
typeName: 'Query',
65+
throwOnError: false,
6466
handler: otherHandler,
6567
});
6668
expect(console.warn).toHaveBeenCalledWith(
6769
"A resolver for field 'getPost' is already registered for 'Query'. The previous resolver will be replaced."
6870
);
6971
});
7072

71-
it('will not replace the resolver if the event type is different', () => {
73+
it("doesn't replace the resolver if the event type is different", () => {
7274
// Prepare
7375
const registry = getRegistry();
7476
const originalHandler = vi.fn();
@@ -89,13 +91,17 @@ describe('Class: RouteHandlerRegistry', () => {
8991
// Assess
9092
expect(registry.resolvers.size).toBe(2);
9193
expect(registry.resolvers.get('Query.getPost')).toEqual({
94+
aggregate: true,
9295
fieldName: 'getPost',
9396
typeName: 'Query',
97+
throwOnError: false,
9498
handler: originalHandler,
9599
});
96100
expect(registry.resolvers.get('Mutation.getPost')).toEqual({
101+
aggregate: true,
97102
fieldName: 'getPost',
98103
typeName: 'Mutation',
104+
throwOnError: false,
99105
handler: otherHandler,
100106
});
101107
});

packages/idempotency/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
],
151151
"devDependencies": {
152152
"@aws-lambda-powertools/testing-utils": "file:../testing",
153-
"@aws-sdk/client-dynamodb": "^3.858.0",
154-
"@aws-sdk/lib-dynamodb": "^3.858.0",
153+
"@aws-sdk/client-dynamodb": "^3.859.0",
154+
"@aws-sdk/lib-dynamodb": "^3.859.0",
155155
"aws-sdk-client-mock": "^4.1.0"
156156
}
157157
}

0 commit comments

Comments
 (0)