-
Notifications
You must be signed in to change notification settings - Fork 735
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
Setters for all generated models, like pre-v1.0 allowed #2883
Comments
This feature is nearly complete and will be in the 1.1 release coming very soon. It's being tracked in #2551. Currently you can beta test this functionality in the |
That's great. Looking forward to that. What's the ETA on final release? I tried using Xcode says in |
In the code generated files I now get stuff like this: I've deleted and cleaned everything, so this is freshly generated. config file fwiw: {
"schemaName" : "FooBar",
"options" : {
"cocoapodsCompatibleImportStatements" : true,
"schemaDocumentation": "include",
},
"schemaDownloadConfiguration": {
"downloadMethod": {
"introspection": {
"endpointURL": "my url",
"httpMethod": {
"POST": {}
},
"includeDeprecatedInputValues": false,
"outputFormat": "SDL"
}
},
"downloadTimeout": 60,
"headers": [],
"outputPath": "ApolloCodegen/schema.graphqls/"
},
"input" : {
"operationSearchPaths" : [
"foobar/graphql/**/*.graphql"
],
"schemaSearchPaths" : [
"ApolloCodegen/**/*.graphqls"
]
},
"output" : {
"testMocks" : {
"none" : {
}
},
"schemaTypes" : {
"path" : "foobar/API",
"moduleType" : {
"embeddedInTarget" : {
"name" : "foobar"
}
}
},
"operations" : {
"inSchemaModule" : {
}
}
}
} |
Thanks for those reports! Looks like I made a little bug for Cocoapods users! I'll get that resolved. I am hoping to get this version out ASAP. Goal was end of this week, but I've hit a few roadblocks that I'm trying to sort out at the moment. |
Great! Thanks for the update and glad I could help locate a CocoaPods issue. Looking forward to the new release! |
@JoeFerrucci These issues should now be fixed in the release branch. Let me know if you are able to try this out successfully now! |
@AnthonyMDev I no longer see the build error I mentioned but I still do not see the setters - they're still just computed properties. pod 'Apollo', :git => 'https://github.com/apollographql/apollo-ios.git', :branch => 'release/1.1', :commit => 'ae7acbd84b8ba2c499ba3105aca37d057e8feb78'
pod 'Apollo/WebSocket', :git => 'https://github.com/apollographql/apollo-ios.git', :branch => 'release/1.1', :commit => 'ae7acbd84b8ba2c499ba3105aca37d057e8feb78' I see that the pods did update from I regenerated the code but I'm still not seeing any setters and the data types are still SelectionSets (fwiw). |
You will need to set the configuration option to generate initializers. They are not currently generated by default. I don't have documentation written for that yet, but the config options have been added to In the "selectionSetInitializers" : {
"localCacheMutations" : true,
"namedFragments" : true,
"operations" : true
} |
That will do it! 🙂 Seems to be good now. I have a long road of migration ahead of me. I need clarification on one thing: @AnthonyMDev In pre-v1, I was allowed to pass Pre-V1:func doSomething(name: String?) {
let query = SomeQuery(name: name)
...
} V1.x:func doSomething(name: String?) {
// I now have to pass .none to indicate a nil value - is this correct?
let query = SomeQuery(name: name ?? .none)
...
} |
For input parameters on queries, yes this is the intended behavior in 1.0. Nullable input parameters are wrapped in a See the inline documentation for |
Yep, I read it. Just needed confirmation of my understanding. Seems like a pain 😅 but it's fine; I understand the reasoning. |
Hi @AnthonyMDev If you have an existing object of a SelectionSet instance and you want to modify the property directly, |
Not sure if this is a bug or not, maybe it isn't: I have public init(tags: [Tag?]? = nil) {
let objectType = API.Objects.ContentObject
self.init(_dataDict: DataDict(objectType: objectType,
data: [
"__typename": objectType.typename,
"tags": tags
]))
} has Can you shed some light on this please? 🙏 thanks. |
There are no setters for Currently, for dummy data and mocks, I recommend using the TestMocks or initializing new SelectionSet models when your data changes. This second comment looks like a bug. We're definitely still in development on 1.1, so not super surprised to see bugs here. Can you please make a new issue for this bug and I will look into it! |
The bug you mentioned here is fixed in the 1.1 Beta release which is now out! |
Question
Before v1.0, we were able to initialize any generated model directly using the default initializer (e.g., from a struct).
Now, some models are now generated as SelectionSets and the properties have no setters and the provided initializers are verbose and ugly; Unlike the InputObject type where it provides setters for each property, making it easy to manually construct the models.
How can we generate setters for every generated model?
The text was updated successfully, but these errors were encountered: