1 | resource "aws_appsync_resolver" "Comment_date" { |
2 | api_id = aws_appsync_graphql_api.appsync.id |
3 | type = "Comment" |
4 | field = "date" |
5 | |
6 | runtime { |
7 | name = "APPSYNC_JS" |
8 | runtime_version = "1.0.0" |
9 | } |
10 | code = <<EOF |
11 | export function request(ctx) { |
12 | return {}; |
13 | } |
14 | |
15 | export function response(ctx) { |
16 | return ctx.result; |
17 | } |
18 | EOF |
19 | kind = "PIPELINE" |
20 | pipeline_config { |
21 | functions = [ |
22 | aws_appsync_function.Comment_date_1.function_id, |
23 | ] |
24 | } |
25 | } |
26 | |
27 | resource "aws_appsync_function" "Comment_date_1" { |
28 | api_id = aws_appsync_graphql_api.appsync.id |
29 | data_source = aws_appsync_datasource.none.name |
30 | name = "Comment_date_1" |
31 | runtime { |
32 | name = "APPSYNC_JS" |
33 | runtime_version = "1.0.0" |
34 | } |
35 | code = <<EOF |
36 | import {util} from "@aws-appsync/utils"; |
37 | export function request(ctx) { |
38 | return { |
39 | version: "2018-05-29", |
40 | payload: util.time.epochMilliSecondsToISO8601(ctx.source.date), |
41 | } |
42 | } |
43 | |
44 | export function response(ctx) { |
45 | if (ctx.error) { |
46 | return util.error(ctx.error.message, ctx.error.type); |
47 | } |
48 | return ctx.result; |
49 | } |
50 | EOF |
51 | } |
52 | |
53 | |