Skip to content

Commit da6b918

Browse files
committed
Revert "fix: failing test for batch resolver aggregate=false"
This reverts commit a2e86ea.
1 parent a2e86ea commit da6b918

File tree

2 files changed

+50
-182
lines changed

2 files changed

+50
-182
lines changed

packages/event-handler/tests/helpers/factories.ts

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,14 @@ const onSubscribeEventFactory = (
7474
events: null,
7575
});
7676

77-
const createEventFactory = ({
78-
fieldName,
79-
args,
80-
parentTypeName,
81-
source,
82-
}: {
83-
fieldName: string;
84-
args: Record<string, unknown>;
85-
parentTypeName: string;
86-
source: Record<string, unknown> | null;
87-
}) => ({
77+
const createEventFactory = (
78+
fieldName: string,
79+
args: Record<string, unknown>,
80+
parentTypeName: string
81+
) => ({
8882
arguments: { ...args },
8983
identity: null,
90-
source: source ? { ...source } : null,
84+
source: null,
9185
request: {
9286
headers: {
9387
key: 'value',
@@ -104,17 +98,11 @@ const createEventFactory = ({
10498
stash: {},
10599
});
106100

107-
const onGraphqlEventFactory = ({
108-
fieldName,
109-
typeName,
110-
args = {},
111-
source = null,
112-
}: {
113-
fieldName: string;
114-
typeName: 'Query' | 'Mutation';
115-
args?: Record<string, unknown>;
116-
source?: Record<string, unknown> | null;
117-
}) => createEventFactory({ fieldName, args, parentTypeName: typeName, source });
101+
const onGraphqlEventFactory = (
102+
fieldName: string,
103+
typeName: 'Query' | 'Mutation',
104+
args: Record<string, unknown> = {}
105+
) => createEventFactory(fieldName, args, typeName);
118106

119107
export {
120108
onPublishEventFactory,

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

Lines changed: 39 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
3333

3434
// Act && Assess
3535
await expect(
36-
app.resolve(
37-
onGraphqlEventFactory({ fieldName: 'getPost', typeName: 'Query' }),
38-
context
39-
)
36+
app.resolve(onGraphqlEventFactory('getPost', 'Query'), context)
4037
).rejects.toThrow(
4138
new ResolverNotFoundException('No resolver found for Query-getPost')
4239
);
@@ -49,10 +46,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
4946

5047
// Act && Assess
5148
await expect(
52-
app.resolve(
53-
onGraphqlEventFactory({ fieldName: 'addPost', typeName: 'Mutation' }),
54-
context
55-
)
49+
app.resolve(onGraphqlEventFactory('addPost', 'Mutation'), context)
5650
).rejects.toThrow(
5751
new ResolverNotFoundException('No resolver found for Mutation-addPost')
5852
);
@@ -65,15 +59,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
6559

6660
// Act && Assess
6761
await expect(
68-
app.resolve(
69-
[
70-
onGraphqlEventFactory({
71-
fieldName: 'relatedPosts',
72-
typeName: 'Query',
73-
}),
74-
],
75-
context
76-
)
62+
app.resolve([onGraphqlEventFactory('relatedPosts', 'Query')], context)
7763
).rejects.toThrow(
7864
new ResolverNotFoundException(
7965
'No batch resolver found for Query-relatedPosts'
@@ -100,11 +86,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
10086

10187
// Act
10288
const result = await app.resolve(
103-
onGraphqlEventFactory({
104-
fieldName: 'getPost',
105-
typeName: 'Query',
106-
args: { id: '123' },
107-
}),
89+
onGraphqlEventFactory('getPost', 'Query', { id: '123' }),
10890
context
10991
);
11092

@@ -135,13 +117,9 @@ describe('Class: AppSyncGraphQLResolver', () => {
135117

136118
// Act
137119
const result = await app.resolve(
138-
onGraphqlEventFactory({
139-
fieldName: 'addPost',
140-
typeName: 'Mutation',
141-
args: {
142-
title: 'Post Title',
143-
content: 'Post Content',
144-
},
120+
onGraphqlEventFactory('addPost', 'Mutation', {
121+
title: 'Post Title',
122+
content: 'Post Content',
145123
}),
146124
context
147125
);
@@ -178,13 +156,9 @@ describe('Class: AppSyncGraphQLResolver', () => {
178156

179157
// Act
180158
const result = await app.resolve(
181-
onGraphqlEventFactory({
182-
fieldName: 'addPost',
183-
typeName: 'Mutation',
184-
args: {
185-
title: 'Post Title',
186-
content: 'Post Content',
187-
},
159+
onGraphqlEventFactory('addPost', 'Mutation', {
160+
title: 'Post Title',
161+
content: 'Post Content',
188162
}),
189163
context
190164
);
@@ -213,11 +187,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
213187
);
214188

215189
// Act
216-
const event = onGraphqlEventFactory({
217-
fieldName: 'getPost',
218-
typeName: 'Query',
219-
args: { id: '123' },
220-
});
190+
const event = onGraphqlEventFactory('getPost', 'Query', { id: '123' });
221191
const result = await app.resolve(event, context);
222192

223193
// Assess
@@ -269,21 +239,13 @@ describe('Class: AppSyncGraphQLResolver', () => {
269239

270240
// Act
271241
const resultQuery = await handler(
272-
onGraphqlEventFactory({
273-
fieldName: 'getPost',
274-
typeName: 'Query',
275-
args: { id: '123' },
276-
}),
242+
onGraphqlEventFactory('getPost', 'Query', { id: '123' }),
277243
context
278244
);
279245
const resultMutation = await handler(
280-
onGraphqlEventFactory({
281-
fieldName: 'addPost',
282-
typeName: 'Mutation',
283-
args: {
284-
title: 'Post Title',
285-
content: 'Post Content',
286-
},
246+
onGraphqlEventFactory('addPost', 'Mutation', {
247+
title: 'Post Title',
248+
content: 'Post Content',
287249
}),
288250
context
289251
);
@@ -329,16 +291,8 @@ describe('Class: AppSyncGraphQLResolver', () => {
329291
// Act
330292
const result = await handler(
331293
[
332-
onGraphqlEventFactory({
333-
fieldName: 'batchGet',
334-
typeName: 'Query',
335-
args: { id: 1 },
336-
}),
337-
onGraphqlEventFactory({
338-
fieldName: 'batchGet',
339-
typeName: 'Query',
340-
args: { id: 2 },
341-
}),
294+
onGraphqlEventFactory('batchGet', 'Query', { id: 1 }),
295+
onGraphqlEventFactory('batchGet', 'Query', { id: 2 }),
342296
],
343297
context
344298
);
@@ -379,16 +333,8 @@ describe('Class: AppSyncGraphQLResolver', () => {
379333
// Act
380334
const result = await handler(
381335
[
382-
onGraphqlEventFactory({
383-
fieldName: 'batchGet',
384-
typeName: 'Query',
385-
source: { id: 1 },
386-
}),
387-
onGraphqlEventFactory({
388-
fieldName: 'batchGet',
389-
typeName: 'Query',
390-
source: { id: 2 },
391-
}),
336+
onGraphqlEventFactory('batchGet', 'Query', { id: 1 }),
337+
onGraphqlEventFactory('batchGet', 'Query', { id: 2 }),
392338
],
393339
context
394340
);
@@ -429,16 +375,8 @@ describe('Class: AppSyncGraphQLResolver', () => {
429375
// Act
430376
const result = await handler(
431377
[
432-
onGraphqlEventFactory({
433-
fieldName: 'batchGet',
434-
typeName: 'Query',
435-
source: { id: 1 },
436-
}),
437-
onGraphqlEventFactory({
438-
fieldName: 'batchGet',
439-
typeName: 'Query',
440-
source: { id: 2 },
441-
}),
378+
onGraphqlEventFactory('batchGet', 'Query', { id: 1 }),
379+
onGraphqlEventFactory('batchGet', 'Query', { id: 2 }),
442380
],
443381
context
444382
);
@@ -474,13 +412,9 @@ describe('Class: AppSyncGraphQLResolver', () => {
474412

475413
// Act
476414
await handler(
477-
onGraphqlEventFactory({
478-
fieldName: 'getPost',
479-
typeName: 'Query',
480-
args: {
481-
title: 'Post Title',
482-
content: 'Post Content',
483-
},
415+
onGraphqlEventFactory('getPost', 'Query', {
416+
title: 'Post Title',
417+
content: 'Post Content',
484418
}),
485419
context
486420
);
@@ -522,13 +456,9 @@ describe('Class: AppSyncGraphQLResolver', () => {
522456

523457
// Act
524458
const result = await app.resolve(
525-
onGraphqlEventFactory({
526-
fieldName: 'addPost',
527-
typeName: 'Mutation',
528-
args: {
529-
title: 'Post Title',
530-
content: 'Post Content',
531-
},
459+
onGraphqlEventFactory('addPost', 'Mutation', {
460+
title: 'Post Title',
461+
content: 'Post Content',
532462
}),
533463
context
534464
);
@@ -552,11 +482,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
552482
// Act
553483
const result = await app.resolve(
554484
[
555-
onGraphqlEventFactory({
556-
fieldName: 'batchGet',
557-
typeName: 'Query',
558-
args: { id: '1' },
559-
}),
485+
onGraphqlEventFactory('batchGet', 'Query', { id: '1' }),
560486
{
561487
key: 'notCompatible',
562488
type: 'unknown',
@@ -585,16 +511,8 @@ describe('Class: AppSyncGraphQLResolver', () => {
585511
aggregate: true,
586512
});
587513
const events = [
588-
onGraphqlEventFactory({
589-
fieldName: 'batchGet',
590-
typeName: 'Query',
591-
args: { id: '1' },
592-
}),
593-
onGraphqlEventFactory({
594-
fieldName: 'batchGet',
595-
typeName: 'Query',
596-
args: { id: '2' },
597-
}),
514+
onGraphqlEventFactory('batchGet', 'Query', { id: '1' }),
515+
onGraphqlEventFactory('batchGet', 'Query', { id: '2' }),
598516
];
599517

600518
// Act
@@ -622,16 +540,8 @@ describe('Class: AppSyncGraphQLResolver', () => {
622540
raiseOnError: true,
623541
});
624542
const events = [
625-
onGraphqlEventFactory({
626-
fieldName: 'batchGet',
627-
typeName: 'Query',
628-
args: { id: '1' },
629-
}),
630-
onGraphqlEventFactory({
631-
fieldName: 'batchGet',
632-
typeName: 'Query',
633-
args: { id: '2' },
634-
}),
543+
onGraphqlEventFactory('batchGet', 'Query', { id: '1' }),
544+
onGraphqlEventFactory('batchGet', 'Query', { id: '2' }),
635545
];
636546

637547
// Act
@@ -661,21 +571,9 @@ describe('Class: AppSyncGraphQLResolver', () => {
661571
raiseOnError: false,
662572
});
663573
const events = [
664-
onGraphqlEventFactory({
665-
fieldName: 'batchGet',
666-
typeName: 'Query',
667-
args: { id: '1' },
668-
}),
669-
onGraphqlEventFactory({
670-
fieldName: 'batchGet',
671-
typeName: 'Query',
672-
args: { id: '2' },
673-
}),
674-
onGraphqlEventFactory({
675-
fieldName: 'batchGet',
676-
typeName: 'Query',
677-
args: { id: '3' },
678-
}),
574+
onGraphqlEventFactory('batchGet', 'Query', { id: '1' }),
575+
onGraphqlEventFactory('batchGet', 'Query', { id: '2' }),
576+
onGraphqlEventFactory('batchGet', 'Query', { id: '3' }),
679577
];
680578

681579
// Act
@@ -704,21 +602,9 @@ describe('Class: AppSyncGraphQLResolver', () => {
704602
raiseOnError: true,
705603
});
706604
const events = [
707-
onGraphqlEventFactory({
708-
fieldName: 'batchGet',
709-
typeName: 'Query',
710-
args: { id: '1' },
711-
}),
712-
onGraphqlEventFactory({
713-
fieldName: 'batchGet',
714-
typeName: 'Query',
715-
args: { id: '2' },
716-
}),
717-
onGraphqlEventFactory({
718-
fieldName: 'batchGet',
719-
typeName: 'Query',
720-
args: { id: '3' },
721-
}),
605+
onGraphqlEventFactory('batchGet', 'Query', { id: '1' }),
606+
onGraphqlEventFactory('batchGet', 'Query', { id: '2' }),
607+
onGraphqlEventFactory('batchGet', 'Query', { id: '3' }),
722608
];
723609

724610
// Act && Assess
@@ -741,13 +627,7 @@ describe('Class: AppSyncGraphQLResolver', () => {
741627
// Act && Assess
742628
await expect(
743629
app.resolve(
744-
[
745-
onGraphqlEventFactory({
746-
fieldName: 'batchGet',
747-
typeName: 'Query',
748-
args: { id: '1' },
749-
}),
750-
],
630+
[onGraphqlEventFactory('batchGet', 'Query', { id: '1' })],
751631
context
752632
)
753633
).rejects.toThrow(

0 commit comments

Comments
 (0)