The generated types implement protocols defined in Apollo, such as GraphQLQuery. For this, they need to import Apollo where most of the code is about cache management and decoding (see example).
For most apps this is fine, but in the context of a very large app where there is a focus on reducing dependencies, this is problematic and there is a need to reduce the dependencies that each generate type creates.
Ideally, things would look like (scroll right!)
Apollo | Consumer application
|
|
---------------------------------- ----------------------------------------
| ApolloTypes | | Type Module A |
| | <--- | |
| protocol GraphQLQuery { ... } | | import ApolloTypes |
|________________________________| | class MyQuery: GraphQLQuery { ... } | ------------------------------
|______________________________________| <--- | Feature Module A |
^ | |
| | import TypeModuleA |
| import Networking |
---------------------------------- ---------------------------------- | |
| Apollo | | Networking Module | <--- | network.send(MyQuery()) |
| | | | |____________________________|
| ApolloClient etc | <--- | Apollo |
| extension GraphQLQuery { ... } | | ... |
|________________________________| |________________________________|
where a type module would not depend on the entirety of Apollo
I think this is the exhaustive list of protocols required by the generated types
GraphQLBooleanCondition
GraphQLField
GraphQLFragment
GraphQLFragmentSpread
GraphQLID
GraphQLInputValue
GraphQLMap
GraphQLMapConvertible
GraphQLMutation
GraphQLOperation
GraphQLOperationType
GraphQLOutputType
GraphQLQuery
GraphQLSelection
GraphQLSelectionSet
GraphQLSubscription
GraphQLTypeCase
GraphQLTypeCondition
GraphQLVariable
JSONDecodable
JSONEncodable
JSONDecodingError
ResultMap
The generated types implement protocols defined in
Apollo, such asGraphQLQuery. For this, they need to importApollowhere most of the code is about cache management and decoding (see example).For most apps this is fine, but in the context of a very large app where there is a focus on reducing dependencies, this is problematic and there is a need to reduce the dependencies that each generate type creates.
Ideally, things would look like (scroll right!)
where a type module would not depend on the entirety of
ApolloI think this is the exhaustive list of protocols required by the generated types
GraphQLBooleanConditionGraphQLFieldGraphQLFragmentGraphQLFragmentSpreadGraphQLIDGraphQLInputValueGraphQLMapGraphQLMapConvertibleGraphQLMutationGraphQLOperationGraphQLOperationTypeGraphQLOutputTypeGraphQLQueryGraphQLSelectionGraphQLSelectionSetGraphQLSubscriptionGraphQLTypeCaseGraphQLTypeConditionGraphQLVariableJSONDecodableJSONEncodableJSONDecodingErrorResultMap