We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fa71f7b commit 91a4916Copy full SHA for 91a4916
1 file changed
examples/pipeline-resolver-with-code/functions/fetchProfile.js
@@ -1,12 +1,20 @@
1
-import { util } from '@aws-appsync/utils';
+import { util, runtime } from '@aws-appsync/utils';
2
3
export function request(ctx) {
4
+ // fetchUser returns null when the user isn't found; short-circuit the
5
+ // pipeline function instead of dereferencing a null result.
6
+ if (ctx.prev.result == null) {
7
+ runtime.earlyReturn(null);
8
+ }
9
return {
10
operation: 'GetItem',
11
key: util.dynamodb.toMapValues({ userId: ctx.prev.result.id }),
12
};
13
}
14
15
export function response(ctx) {
16
17
+ return null;
18
19
return { ...ctx.prev.result, profile: ctx.result };
20
0 commit comments