Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
calvincestari opened this issue Mar 21, 2024 · 0 comments
Labels
codegen Issues related to or arising from code generation enhancement Issues outlining new things we want to do or things that will make our lives as devs easier low-priority

Comments

@calvincestari
Copy link
Member

calvincestari commented Mar 21, 2024

Related to #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

  • 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.
@calvincestari calvincestari changed the title bug: SchemaConfiguration should be scoped within the namespace enum for embeddedInTarget module type SchemaConfiguration should be scoped within the namespace enum for embeddedInTarget module type Mar 21, 2024
@calvincestari calvincestari added enhancement Issues outlining new things we want to do or things that will make our lives as devs easier codegen Issues related to or arising from code generation labels Mar 21, 2024
@calvincestari calvincestari added this to the Patch Releases (1.x.x) milestone Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Issues related to or arising from code generation enhancement Issues outlining new things we want to do or things that will make our lives as devs easier low-priority
Projects
None yet
Development

No branches or pull requests

2 participants