-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
AWSJSON containing Array is typed as string but comes out as Array from DataStore #11013
Comments
Hi @caridavidson thank you for raising this issue. This sounds like a typescript issue. Can you please share an example of the error/issue you're seeing when attempting to convert the I tried creating a ex: const workSpace = await DataStore.save(
new Workspace({
owners: [user.attributes!.email],
notes: JSON.stringify([
{
details: {
value: "foo",
},
type: "string",
},
]),
})
); I then tried querying a WorkSpace for its notes but the type seems to be If DataStore is returning the data as an |
Overriding the type to string would be a workaround, I agree, and it's what I've done. But I still figured you'd want to know about the bug.. Casting to the errors I get depend on how I try to deal with the problem: When casting" If uncasted: |
@caridavidson Yes, this is definitely worth mentioning. The team is currently working on improving the TS developer experience around GraphQL and DataStore so this very helpful. I will mention this issue to the team for consideration towards the current work. Lastly, for that issue regarding casting, can you try casting the value like so? |
We have published an RFC on our plan for improving TypeScript support in Amplify JS & would love to get your feedback & suggestions! |
I've moved on from this and have a workaround. It seems odd to close an
issue just because the reporter doesn't respond when the bug still exists.
…On Fri, 24 Mar 2023, 19:44 Chris Bonifacio, ***@***.***> wrote:
Reopened #11013 <#11013>.
—
Reply to this email directly, view it on GitHub
<#11013 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALMF45FQUI3ZVS64XIKPLUDW5XTP3ANCNFSM6AAAAAAVEMMJNM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
With the release of the latest major version of Amplify (aws-amplify@>6), this issue should now be resolved! Please refer to our release announcement, migration guide, and documentation for more information. As a note, we still haven't been able to reproduce this. Let us know if you continue to experience this @caridavidson after upgrading to v6 of Amplify. |
Before opening, please confirm:
JavaScript Framework
Vue3
Amplify APIs
GraphQL API, DataStore
Amplify Categories
api
Environment information
Describe the bug
There were already a couple of tickets about this, but the problem seems to still exist.
I'm using an
AWSJSON
type in my graphQL model.I have given it a value of Array
The code that is generated returns a model with type
string | null
The object that is returned from
DataStore
is anArray<Record>
This makes it difficult / cumbersome to convert to/from JSON without errors.
Expected behavior
If the value is meant to be a JSON string, then it should be a JSON string.
If the value is an array or object, then it should be typed appropriately in the model that is generated.
Reproduction steps
Code Snippet
Log output
Using this block for the output of what's coming out of the DataStore
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: