Comments (5)
There are actually 2 separate issues that you've correctly identified:
- Codegen isn't conforming enums to
Codable
- DataStore expects the associated type to be a
@model
, which doesn't really make sense for enum values. We may in the end elect to treat them as models, but it doesn't seem right for a customer to have to tag an enum value with@model
. We're working on this and will update when we have more info.
These two may end up devolving into a single root cause (again as you've correctly identified), but for now it makes sense to consider them separately.
from amplify-swift.
Quick update on this:
So far the best I could come up with was to introduce a new contract to enums, something like PersistableEnum
:
enum PostStatus: String, PersistableEnum {
case draft
case published
}
protocol PersistableEnum {
var enumValue: String { get }
}
extension PersistableEnum
where Self: RawRepresentable, Self.RawValue == String {
var enumValue: String { return rawValue }
}
if let value = PostStatus.draft as? PersistableEnum {
print(value.enumValue)
}
that way we can always check Any
for PersistableEnum
conformance and call enumValue
. Not 100% clear yet how I'm going to de-serialize a String
back to PersistableEnum
.
I tried using Swift built-in types only, like RawRepresentable<String>
, StringRepresentable
and CustomStringConvertible
with no luck
from amplify-swift.
Hello, trying to understand this issue (as I think I have just hit it and I created a ticket that might be duplicate of this one with a different symptom)
Assuming my schema is:
enum Gender {
male,
female,
}
type Person @model
(mutations: { create: "newPerson", update: "updPerson", delete: "delPerson" } ) {
id: ID!
name: String!
gender: Gender!
}
The generated enum is not supported at the time of applying a mutation, right?
I created a ticket indicating the enum doesn't conform with the Codable
protocol but reading this ticket (and based on my current code that is crashing Fatal error: Model with name Gender could not be found.: file
) I assume it is the same root cause.
If that is the case, I can close the #246 ticket as duplicate.
from amplify-swift.
Fair enough.
Looking forward to the decision.
from amplify-swift.
This was resolved by PR #334
from amplify-swift.
Related Issues (20)
- 我自己能不能为Amplify v2支持CocoaPods? HOT 2
- AwsCommonRuntimeKit potentially needs a privacy manifest HOT 6
- AWS Amplify v2 fetchAuthSession returns isSignedIn False in Swift : After migrating Amplify v1 to v2 in iOS Swift, on app reopening HOT 5
- Login with Microsoft AD authentication using signInWithWebUI is not successful. HOT 1
- Improve login/logout with Google experience. HOT 3
- File at path does not exist HOT 10
- Update SQLite.swift HOT 5
- build error on xcode15.3 HOT 8
- Update `aws-sdk-swift` dependency to v0.42.0 HOT 2
- can not receive update Subscription event on 2.29.2 SDK version HOT 5
- Crash in OutgoingMutationQueue.doStart(api:mutationEventPublisher:reconciliationQueue:) HOT 2
- Login fails post logout after First Successful signup/signin HOT 6
- amplifyconfiguration.json & awsconfiguration.json not updating when switching amplify environments HOT 5
- Login can not switch another google account HOT 3
- Amplify.Auth.signInWithWebUI Hang and always return time out, because authZState always return error HOT 9
- High Memoey leak HOT 4
- Amplify API Unathorized error Error HOT 25
- `HostedUIASWebAuthenticationSession.showHostedUI` never calls the continuation when `aswebAuthenticationSession.canStart` is false HOT 1
- Retrying signing challenge doesn't work HOT 1
- GraphQL query works in appsync console but not on client HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-swift.