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
SchemaConfiguration.swift is one of the files that does not get overwritten once it already exists. This should not be a problem because current compilation is unaffected by this bug.
This is not considered a breaking change because the only place that references the SchemaConfiguration type is SchemaMetadata which is already generated within the enum namespace. This change will make it clearer for the compiler which SchemaConfiguration is being referenced without needing to use the fully qualified namespace.
Updating SchemaMetadata to use the fully qualified namespace would be a breaking change because that type may not exist in previously generated schema modules. So do not do this as part of this work.
Related to https://github.com/apollographql/apollo-ios/issues/3357.
Bug
Below is an example
SchemaConfiguration
type that is generated when theembeddedInTarget
schema module output type is used: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:Considerations
SchemaConfiguration.swift
is one of the files that does not get overwritten once it already exists. This should not be a problem because current compilation is unaffected by this bug.SchemaConfiguration
type isSchemaMetadata
which is already generated within the enum namespace. This change will make it clearer for the compiler whichSchemaConfiguration
is being referenced without needing to use the fully qualified namespace.SchemaMetadata
to use the fully qualified namespace would be a breaking change because that type may not exist in previously generated schema modules. So do not do this as part of this work.