-
Notifications
You must be signed in to change notification settings - Fork 722
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
GraphQLAPI generates incorrect init #123
Comments
I'm not sure what you mean by initial values, but values in Did you know you can convert any fragment into any other fragment (as long as it has a value for all the fields) by using a simple constructor? So if you have a |
I can't use that awesome fragment trick here because some fields are missing (which I'll exclude once directives work), but I am using it elsewhere where I can. 👍 And I don't think you're correct about the snapshot values, at least we are seeing snake-case on the fragments returned from the query.
Also, the code snippets in my original post are from the GraphQLAPI and confirm this. |
Ah, you're right! The And the initializer uses the property name, so that's definitely a bug: public init(name: String, mass: Double? = nil, fooBar: String) {
self.init(snapshot: ["__typename": "Human", "name": name, "mass": mass, "fooBar": fooBar])
}
public var fooBar: String {
get {
return snapshot["foo_bar"]! as! String
}
set {
snapshot.updateValue(newValue, forKey: "foo_bar")
}
} |
👍 So will the generated API eventually have the properties also reflect the schema name? Or will you guys be fixing it differently? And just so we have a sense for planning, do you have a rough estimate when this will be fixed... whatever that fix might be? |
I just published a new release, should be fixed in |
Great; thanks! |
Since directives aren't working, we are doing a work-around where we need to map the return from one fragment to another -- in essence, an offer fragment, and another offer fragment with a few fields missing.
To do the conversion, I wanted to use the init on the offer fragment to map the other fragment into it, but I noticed an issue. The initial values are stored in a dictionary with keys in snake case (i.e., "large_url"), but the init stores values in the dictionary with keys in camel case (i.e., "largeUrl").
The text was updated successfully, but these errors were encountered: