-
Notifications
You must be signed in to change notification settings - Fork 199
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
feat: [API] Merge non-GraphQL spec error fields into GraphQLError.extensions #401
Conversation
1648234
to
042391e
Compare
...yPlugin/Sync/MutationSync/OutgoingMutationQueue/ProcessMutationErrorFromCloudOperation.swift
Outdated
Show resolved
Hide resolved
63cf3d9
to
5ac3f14
Compare
return GraphQLError(message: graphQLError.message, | ||
locations: graphQLError.locations, | ||
path: graphQLError.path, | ||
extensions: !mergedExtensions.isEmpty ? mergedExtensions : nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of the !
you could just invert the ternary result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
if key == "message" || | ||
key == "locations" || | ||
key == "path" || | ||
key == "extensions" || | ||
mergedExtensions.keys.contains(key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could have a list of keys and then append the mergedExtensions.keys
into that list and just check for contains(key)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, updating
throw APIError.unknown(""" | ||
Unexpected failure while decoding GraphQL response containing errors: | ||
\(String(describing: graphQLErrors)) | ||
""", "", error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should that second argument contain something? Does the "report to AWS" suggestion fit here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like we already do that when exposed to the developer
case .unknown(_, let recoverySuggestion, _):
return """
\(recoverySuggestion)
\(AmplifyErrorMessages.shouldNotHappenReportBugToAWS())
"""
Description of changes:
This change merges the graphQL error values with keys which do not match the GraphQL spec into the extensions JSON.
Android PR for reference aws-amplify/amplify-android#392
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.