Hey guys, been playing around with an obj-c target on my fork of this repo (https://github.com/kieranlafferty/apollo-codegen)
Still not full working yet but thought it may be of interest to some people who are also interested in contributing to getting the codegen to work for objc.
Interested to get some early feedback. Thanks again for making such an awesome project!
That looks great! Thanks for getting this started.
Have you thought about how you'd like to approach the runtime support for the generated classes yet? You'll probably run into some trouble using apollo-ios from Objective-C right now, because the Swift method signatures are incompatible (generics, etc.), but it might be possible to find alternative ways of exposing the core functionality to Objective-C.
Not a whole lot yet..
So far have the focus has been on getting the data types to map in objective-c with autocomplete and proper typecasting. the
I can imagine if something like apollo-core acts as a simple network transport that passes the server data as json/dictionary to swift/objc layer then the magic of the swift generics can be abstracted on top of that while allowing objc mapping to happen by parsing the dictionary to the codegen classes to ensure type safety on objc.
Something like
apollo-core (network layer + json -> dictionary mapping)
- apollo-swift (generics mapping)
- apollo-codegen (mapping to codegenned model layer)
- apollo-objc (codegenned mapping from json to model layer)
Then as long as apollo-core was compatible with both objc/swift the the apollo-swift portion could implement the type checking and generics
I don't have a great solution yet for achieving the effect of the generics in objc.
Was thinking just providing a block with (id result, NSError *error) and then having the consumer of the API manually typecast the response type from (id) => ( _MyQuery_ Response) and the rest of the code completion would take over from there
As in, consumer of the api would manually change
[client fetch:query
completion:(id _Nonnull response, NSError _Nullable*error) ^{
}]
to
[client fetch:query
completion:(MyQueryResponseData _Nonnull *response, NSError _Nullable*error) ^{
}]
@martijnwalraven should we keep this issue open? I think that many things evolved since the last update of this issue. I understand that the ObjC target would be interesting but we may need to wait for the next big refactor before being able to do anything about it...
Dear all
I'm trying to use Apollo in an obj-C project, and was wondering if you guys have a clean solution to achieve this ?
Thanks
Most helpful comment
Dear all
I'm trying to use Apollo in an obj-C project, and was wondering if you guys have a clean solution to achieve this ?
Thanks