-
Notifications
You must be signed in to change notification settings - Fork 199
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
Support enums in code generated models #111
Comments
- Fix bug where MutationEvent is marked syncable - Setting MutationEvent.mutationType to be a String pending resolution of #111 - Make StorageEngine rely on a SyncEngineFactory in the injection constructor, and make syncEngine a lazily initialized property since there's a circular reference there. - Weakened circular references to avoid retain cycles
Quick update on this: So far the best I could come up with was to introduce a new contract to enums, something like 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 I tried using Swift built-in types only, like |
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 If that is the case, I can close the #246 ticket as duplicate. |
There are actually 2 separate issues that you've correctly identified:
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. |
Fair enough. Looking forward to the decision. |
This fixes problems reported in several issues: #111 #240 #246 #318 #314 **Notes:** - added support for SQLite to handle Enums - added support for SQLite to handle non-model types: - custom Codable structs - codable arrays - added tests to make sure the right values are represented as SQLite bindings - remove field type string representation - re-organized schema related files - add support for Enum and non-model types - remove commented code - fix SQLite Int64 precision - improve documentation and test cases - better error handling and parameter naming - addressed PR feedback - add tests for `AnyEncodable` - renamed variables for improved readability - improved error message - minor naming changes to address PR feedback - update cocoapods version to be in sync with master **Tests:** - added a model that has all types of fields to make it easier to visualize how data is represented on SQLite **Pending:** - More documentation - GraphQL clenup on API category
This was resolved by PR #334 |
Given the following type:
Registering the type as a model fails:
It looks like it's not going to be as simple as just detecting the
type
inModelField.typeDefinition
, since the incomingtype
on the field isMutationType
, and I don't see any path to find that it's actually anenum
.The text was updated successfully, but these errors were encountered: