Amplify-ios: Codegen failure: Enum types generates an invalid type definition as enums do not implement Codable

Created on 10 Dec 2019  路  5Comments  路  Source: aws-amplify/amplify-ios

Let's take the following example:

enum Gender {
  male,
  female,
  none,
  nonBinary,
  unspecified
}

type Person @model 
  (mutations: { create: "newPerson", update: "updatePerson", delete: null } ) {

  id: ID!
  name: String!
  gender: Gender!
}

I would expect this generation to be pretty straight forward, but building this code will generate an error indicating Person is not decodable. Checking the generated definition I can see a Person.swift, Person+Extensions.swift and a Gender.swift file without any extension.

Fixing this issue is simple, basically just add the extension file manually and type in:
extension Gender: Codable { }... But I would imagine this is the responsibility of the code generator to put in place.

bug datastore

All 5 comments

Hi @rodrigoelp, support for codable enums just landed in master. We will release Amplify soon along with a new version of the Amplify CLI with the codegen updated. I'll keep this issue open until the release is out.

Has this been fixed yet? I have the same issue in my project at the moment.

Still same issue..
@drochetti When it will be released?

Hey @rodrigoelp @yosuke1985 @AnruStander we just released a stable v1.0.0.

Enums should work correctly in 1.0.0. Can you try and let me know if that fixes the issue for you?


I appreciate your patience and the fact you tried our unstable preview and provided valuable feedback and insights with your issue report. I hope the stable release fixes things for you.

We also have a brand new Discord server for Amplify related topics. Feel free to hit me up there to talk about your use cases and challenges with the new APIs and docs. https://discord.gg/amplify

Closing this issue. Feel free to open a new one if you have problems with the stable version of Amplify.

Was this page helpful?
0 / 5 - 0 ratings