Skip to content

Commit 9d3e9b0

Browse files
authored
fix: Fixed APPSYNC_JS resolvers for both kinds (UNIT and PIPELINE) (#55)
1 parent fb7debd commit 9d3e9b0

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

examples/complete/main.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ EOF
269269
]
270270
}
271271

272+
"Query.singleComment" = {
273+
kind = "UNIT"
274+
type = "Query"
275+
field = "singleComment"
276+
code = file("src/function.js")
277+
runtime = {
278+
name = "APPSYNC_JS"
279+
runtime_version = "1.0.0"
280+
}
281+
data_source = "dynamodb1"
282+
}
283+
272284
"Query.user" = {
273285
kind = "PIPELINE"
274286
type = "Query"

examples/complete/schema.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,16 @@ type User {
1212
name: String
1313
}
1414

15+
type Comment {
16+
id: ID !
17+
comment: String!
18+
}
19+
1520
type Query {
1621
singlePost(id: ID!): Post
1722
none(dummyString: String!): String!
1823
user(id: ID!): User
24+
singleComment(id: ID!): Comment
1925
}
2026

2127
schema {

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,10 @@ resource "aws_appsync_resolver" "this" {
201201
}
202202

203203
# code is required when runtime is APPSYNC_JS
204-
code = try(each.value.kind == "PIPELINE" && each.value.runtime.name == "APPSYNC_JS", false) ? each.value.code : null
204+
code = try(each.value.runtime.name == "APPSYNC_JS", false) ? each.value.code : null
205205

206-
request_template = lookup(each.value, "request_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_request_template : try(each.value.kind == "PIPELINE" && each.value.runtime.name == "APPSYNC_JS", false) ? null : "{}")
207-
response_template = lookup(each.value, "response_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_response_template : try(each.value.kind == "PIPELINE" && each.value.runtime.name == "APPSYNC_JS", false) ? null : "{}")
206+
request_template = lookup(each.value, "request_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_request_template : try(each.value.runtime.name == "APPSYNC_JS", false) ? null : "{}")
207+
response_template = lookup(each.value, "response_template", tobool(lookup(each.value, "direct_lambda", false)) ? var.direct_lambda_response_template : try(each.value.runtime.name == "APPSYNC_JS", false) ? null : "{}")
208208

209209
data_source = lookup(each.value, "data_source", null) != null ? aws_appsync_datasource.this[each.value.data_source].name : lookup(each.value, "data_source_arn", null)
210210

0 commit comments

Comments
 (0)