Apollo-ios: Codegen requires all objects to implement equatable.

Created on 22 Jan 2019  路  15Comments  路  Source: apollographql/apollo-ios

I'm pretty sure it's because of public typealias ResultMap = [String : Any?]. Because Any? is not Equatable. If it was [String : AnyHashable?], this wouldn't be a problem. In reality, the objects should already be generated with equatable.

I'm generally concerned about the code quality codegen provides and would greatly appreciate an alternative solution.

codegen

Most helpful comment

Yes! Please follow along with the Codegen Project to see where things are at - working on that at the same time as a few other things though.

All 15 comments

An alternative solution would be, only use codegen for the queries, not the responses.

In reality, the objects should already be generated with equatable.

I definitely agree, would make usage with IGListKit a lot more convenient.

I definitely agree, would make usage with IGListKit a lot more convenient.

We make very heavy usage of IGListKit in our app, so had to have this. I ended up using a little Sourcery template to codegen Equatable for Apollo's entire generated API. See below:
https://gist.github.com/SirensOfTitan/5f9feb2dca067e4b4152609e1851c028

... I am not sure if my work is 100% correct, but it works in practice pretty well. I'd be willing to setup a PR for the official codegen client once the Meteor folks hire their fulltime iOS engineer.

@SirensOfTitan Hi I'm the fulltime iOS engineer who was (finally) hired, let me know if I can be of help here!

Hello @designatednerd! I haven't looked at what is being generated in a while, but if it's still the same, then I'd assume what I put in the issue description is still relevant. There's some higher level difficulties I have had with the codegen, but those would be off topic here, as this issue is pretty explicit.

We are going to have a few changes landing soonish, but I'll put this in to take a look at when we're dealing with that.

I think we also should consider autogenerate the Hashable interface as the new Diffable in iOS 13 requires that 馃殌

Yes Hashable is definitely happening in addition to equatable - I've been doing that in some behind the scenes stuff prepping for updated codegen

@designatednerd Is this still coming or do we need someone to pick up the work for this?

Yes! Please follow along with the Codegen Project to see where things are at - working on that at the same time as a few other things though.

What's the status on this? 馃檪

Coming along! Codegen itself got blocked for a bit so I shifted to working on the networking stack, but once that's out I'll be back on Codegen and auto-Equatable conformance is definitely a big goal.

Awesome 馃檶 With auto Equatable and Hashable conformance it would be a lot easier to implement diffing for table views and collection views

Yes, aboslutely!

looking forward to it

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ermik picture ermik  路  4Comments

hiteshborse12 picture hiteshborse12  路  4Comments

jeromeDms picture jeromeDms  路  5Comments

marcoreni picture marcoreni  路  3Comments

maxsz picture maxsz  路  4Comments