Open ericlewis opened 4 years ago
This is 100% in the plan for the shift to swift based codegen: https://github.com/apollographql/apollo-ios/issues/939
@designatednerd fantastic! I built a semi-hacky way to handle identifiable generation: https://github.com/ericlewis/StarWarz/blob/master/StarWars/process.js
usage: sourcekitten structure --file API.swift > output.json && node process.js
Also of interest is how I integrate Apollo with SwiftUI perhaps too! 👍
Where do you add these extensions? in which file and where, new to ios and apollo and swiftui here...
It would be awesome if the swift codegen had an option to detect and automatically generate the correct protocols to conform to
Identifiable
when aGraphQLSelectionSet
has anid
property.It is currently possible to write code to conform, but it is fragile:
Proposed Solution
The proposed solution would be to add an optional flag and generate the extensions in the current codegen, but it may perhaps be easier to traverse the AST of the generated API as a separate step. Advice is welcome if folks have done this before.
Reasoning
While it is currently possible to support this solution today- it is tedious to rewrite the same code.