fix(amplify-appsync-simulator): appsync scalars #5705
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
Fixes #5207
Description of changes:
Several issues here.
AWS scalars were not used at all
AWS scalars were defined, but never injected in the schema. This is now fixed.
Please let me know if this was intentional (for some reason)
AWSPhone
was needs to be instantiated in order to be injected into the schema.Instead, the class itself was passed.
AWSPhone
also seems to accept some options for the country. Since this was not used at all until now, I just left the defaults.AWSJSON
Finally, this fixes Value returned by amplify-appsync-simulator for AWSJSON fields doesn't match AppSync #5207
AWSJSON are stringified in AppSync but were returned as objects in the simulator.
According to the doc and the reverse engineering I have been doing, it should act as follow:
As an Input
JSON strings are parsed as values before getting to mapping template. This means:
"{\"Foo\":\"Bar\"}"
becomes{Foo: "Bar"}
(object, orMap
)"true"
(the string) becomestrue
(the boolean)"1"
(the string) becomes1
(the integer)"\"Hello\""
(double quotes are important) becomes theHello
stringetc.
Any array of the above should also work. Example:
"[\"Hello\", \"World\"]"
"Hello"
is an invalid json representation and fails.Any non-string value should fail.
As an output
Basically, any output will be encoded as a JSON
{Foo: "Bar"}
becomes{"Foo": "Bar"}
, and so on... (Basically, the reverse of the above)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.