Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: nullreference error #12

Merged
merged 2 commits into from May 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions appSyncClient.go
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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionName is Already an existing variable that contains the function name.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end I removed the functionName variable. There are plenty of references to the function variable... so felt better to just do that instead of creating separate functionName variable

functionStatistics.FailedToCreate++
} else {
functions = append(functions, function)
functions = append(functions, functionResponse)
mhd999 marked this conversation as resolved.
Show resolved Hide resolved
functionStatistics.Created++
}
}
Expand Down