amplify-codegen
amplify-codegen copied to clipboard
DataStore codegen wrong message for union types
Describe the bug
When a union type is defined in the schema.graphql, an attempt to generate DataStore models fails with the following message:
Unknown type SearchResult for field items. Did you forget to add the @model directive
Amplify CLI Version
4.21.1
To Reproduce
- Create a schema with a union type.
- run
amplify codegen models
Sample schema:
union SearchResult = Contact | User | Entity
type SearchableConnection {
items: [SearchResult]
nextToken: String
total: Int
}
Expected behavior A clear message stating that union types are not supported in DataStore.
Screenshots N/A.
Desktop (please complete the following information):
- OS:
MacOS 10.14.6 - Node Version:
12.8.0
Additional context Reported originally by @lenarmazitov: https://github.com/aws-amplify/amplify-ios/issues/544
is there a plan to support union types?
would it be possible for datastore to ignore the declarations of union types instead of throwing an error? and have part of an API using union types without datastore, and still use datastore for things it supports?
Bump? Having the same issue here. Added an issue in the codegen repo https://github.com/aws-amplify/amplify-codegen/issues/143
Would be nice to atleast be able to use the union types even though it's not supported for datastore
Hey yall :wave: thanks for raising this! I'll transfer to the codegen repo for better assistance
Ca we please have an update on this? I think this is a pretty necessary part of GraphQL. Data store should seriously support unions.
There is an update about this topic??
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.