-
Notifications
You must be signed in to change notification settings - Fork 79
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
unexpected behavior of @default
with non-string types
#76
Comments
NOTE: this is working as expected. add more examples to the docs for non-string types |
So does it mean we always need to use string value whatever the type of the field is? |
I can't see any docs update yet but I think we can't use non-string as default value regardless of the corresponding field type. |
> The value parameter must be formatted as a string regardless of the corresponding field type. I can confirm that it works for Int type with default value parameter as string. |
Is there documentation for what string equivalents are allowed? (e.g., "nil" or JSON "null" or Python "None", IEEE 754 "NaN", "6.022E23", etc) |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Before opening, please confirm:
How did you install the Amplify CLI?
pnpm
If applicable, what version of Node.js are you using?
v16.13.2
Amplify CLI Version
7.6.25
What operating system are you using?
mac
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
no
Amplify Categories
api
Amplify Commands
Not applicable
Describe the bug
@default
does not work for non-string types unless supplied default value is passed as a string. In the example below we are attempting to set default values based on the field type.However this results in an error upon running
amplify api gql-compile
:After modifying the schema to pass default values as strings, we are then able to successfully compile the GraphQL schema and observe VTL templates are generated with the correct default values:
and the resulting
Mutation.createTodo.init.2.req.vtl
for exampleExpected behavior
Default value adheres to field type
Reproduction steps
amplify init -y
amplify add api
> GraphQL > Blank schemaamplify api gql-compile
GraphQL schema(s)
# Put schemas below this line
Log output
Additional information
https://docs.amplify.aws/cli/graphql/data-modeling/#assign-default-values-for-fields
The text was updated successfully, but these errors were encountered: