Skip to content

Commit

Permalink
fix: Fixed APPSYNC_JS resolvers for both kinds (UNIT and PIPELINE) (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagoodhand authored Aug 30, 2023
1 parent fb7debd commit 9d3e9b0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,18 @@ EOF
]
}

"Query.singleComment" = {
kind = "UNIT"
type = "Query"
field = "singleComment"
code = file("src/function.js")
runtime = {
name = "APPSYNC_JS"
runtime_version = "1.0.0"
}
data_source = "dynamodb1"
}

"Query.user" = {
kind = "PIPELINE"
type = "Query"
Expand Down
6 changes: 6 additions & 0 deletions examples/complete/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ type User {
name: String
}

type Comment {
id: ID !
comment: String!
}

type Query {
singlePost(id: ID!): Post
none(dummyString: String!): String!
user(id: ID!): User
singleComment(id: ID!): Comment
}

schema {
Expand Down
6 changes: 3 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ resource "aws_appsync_resolver" "this" {
}

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

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 : "{}")
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 : "{}")
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 : "{}")
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 : "{}")

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)

Expand Down

0 comments on commit 9d3e9b0

Please sign in to comment.