amplify-codegen icon indicating copy to clipboard operation
amplify-codegen copied to clipboard

DataStore codegen wrong message for union types

Open drochetti opened this issue 5 years ago • 5 comments

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

drochetti avatar Jun 16 '20 00:06 drochetti

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?

olivoil avatar Jun 29 '20 23:06 olivoil

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

arealmaas avatar Apr 06 '21 19:04 arealmaas

Hey yall :wave: thanks for raising this! I'll transfer to the codegen repo for better assistance

josefaidt avatar Jul 29 '21 16:07 josefaidt

Ca we please have an update on this? I think this is a pretty necessary part of GraphQL. Data store should seriously support unions.

ucheNkadiCode avatar Dec 11 '22 12:12 ucheNkadiCode

There is an update about this topic??

AndresPope avatar Jan 26 '23 01:01 AndresPope

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.

github-actions[bot] avatar Jul 02 '24 16:07 github-actions[bot]