apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.87k stars 717 forks source link

SchemaConfiguration should be scoped within the namespace enum for `embeddedInTarget` module type #3360

Open calvincestari opened 6 months ago

calvincestari commented 6 months ago

Related to https://github.com/apollographql/apollo-ios/issues/3357.

Bug

Below is an example SchemaConfiguration type that is generated when the embeddedInTarget schema module output type is used:

enum SchemaConfiguration: ApolloAPI.SchemaConfiguration {
  static func cacheKeyInfo(for type: ApolloAPI.Object, object: ApolloAPI.ObjectData) -> CacheKeyInfo? {
    // Implement this function to configure cache key resolution for your schema types.
    return nil
  }
}

All other types generated are enclosed within a caseless enum that is used as a scoping namespace. SchemaConfiguration should be scoped within that enum too to be generated like this:

extension <schema namespace name> {
  enum SchemaConfiguration: ApolloAPI.SchemaConfiguration {
    static func cacheKeyInfo(for type: ApolloAPI.Object, object: ApolloAPI.ObjectData) -> CacheKeyInfo? {
      // Implement this function to configure cache key resolution for your schema types.
      return nil
    }
  }
}

Considerations