Skip to content

Commit

Permalink
Fix: nullreference error (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkmarek committed May 4, 2022
1 parent 244aa54 commit 603a964
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions appSyncClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ func (client *appSyncClient) CreateOrUpdateResolvers(apiID string, resolversFile
}

for _, function := range resolvers.Functions {
functionName := function.Name

existingFunction := getFunctionByName(functionName, functions)
existingFunction := getFunctionByName(function.Name, functions)

if existingFunction != nil {
_, err := client.updateFunction(&appsync.UpdateFunctionInput{
Expand All @@ -148,7 +146,7 @@ func (client *appSyncClient) CreateOrUpdateResolvers(apiID string, resolversFile
functionStatistics.Updated++
}
} else {
function, err := client.createFunction(&appsync.CreateFunctionInput{
functionResponse, err := client.createFunction(&appsync.CreateFunctionInput{
ApiId: aws.String(apiID),
DataSourceName: aws.String(function.DataSourceName),
RequestMappingTemplate: aws.String(function.RequestMappingTemplate),
Expand All @@ -159,10 +157,10 @@ func (client *appSyncClient) CreateOrUpdateResolvers(apiID string, resolversFile
})

if err != nil {
logger.Println(fmt.Sprintf("Function %s failed to create: %s", *function.Name, err))
logger.Println(fmt.Sprintf("Function %s failed to create: %s", function.Name, err))
functionStatistics.FailedToCreate++
} else {
functions = append(functions, function)
functions = append(functions, functionResponse)
functionStatistics.Created++
}
}
Expand Down

0 comments on commit 603a964

Please sign in to comment.