-
Notifications
You must be signed in to change notification settings - Fork 821
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(amplify-appsync-simulator): appsync scalars #5705
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5705 +/- ##
==========================================
+ Coverage 58.02% 58.04% +0.02%
==========================================
Files 410 410
Lines 18769 18780 +11
Branches 3556 3753 +197
==========================================
+ Hits 10890 10901 +11
+ Misses 7215 7195 -20
- Partials 664 684 +20
Continue to review full report at Codecov.
|
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.
LGTM - thanks for the contribution!
@bboure Thanks a lot for figuring this out! |
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
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.