Skip to content
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

Typing issues on DataStore.save #4

Open
sbue opened this issue Mar 22, 2020 · 5 comments
Open

Typing issues on DataStore.save #4

sbue opened this issue Mar 22, 2020 · 5 comments

Comments

@sbue
Copy link

sbue commented Mar 22, 2020

Consider this example:

// schema.graphql
type UserInfo @model @auth(rules: [{allow: owner}]) {
  id: ID!
  name: string!
  createdAt: AWSDateTime! @auto
}

// another file
await DataStore.save(new UserInfo({...name: "Bob"}));

It results in the following typing issue: "TS2345: ...Property 'createdAt' is missing in type..."
I am able to fix this by changing the createdAt field to readonly createdAt?: string; in the generated models file, but I am escalating this here in case it can be fixed from within this package.

Thanks!

@sbue
Copy link
Author

sbue commented Apr 1, 2020

^ Has this package been tested / used before with DataStore?

@hirochachacha
Copy link
Owner

@sbue No, unfortunately not. That's why I couldn't reply you. I don't know much about DateStore. I need to do some investigation if I want to solve the issue. And I'm not sure whether it's possible.

@PeteDuncanson
Copy link

Damn, just hit this one too. I can't see how this can be fixed within this package, the issue is when DataStore is generating the models (using amplify codegen models). Would have to be handled in the model gen code in Amplify I think.

@PeteDuncanson
Copy link

Which means that as is this transformer can't be used with DataStore.

@PeteDuncanson
Copy link

Actually I'll take that back, the error I was caused by another bug in Amplify at the moment giving me a false negative. Will double check and report back.

aws-amplify/amplify-cli#8113

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants