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

[Swift Codegen] generates 'public' modifier is redundant for type alias declared in a public extension #2302

Closed
kimdv opened this issue Jun 8, 2022 · 5 comments
Assignees

Comments

@kimdv
Copy link
Contributor

kimdv commented Jun 8, 2022

Bug report

There is a lot of 'public' modifier is redundant for type alias declared in a public extension warning which makes it noisy.

public extension CustomerGraphQL {
  public typealias ID = String // warning here

  public typealias SelectionSet = CustomerGraphQL_SelectionSet // warning here

  public typealias InlineFragment = CustomerGraphQL_InlineFragment // warning here

  public enum Schema: SchemaConfiguration { // warning here
    public static func objectType(forTypename __typename: String) -> Object.Type? {
      switch __typename {
      case "Query": return CustomerGraphQL.Query.self
      default: return nil
      }
    }
  }
}

Versions

Please fill in the versions you're currently using:

  • apollo-ios SDK version: 1.0.0 Alpha 6
  • Xcode version: 13.4.1
  • Swift version: 5.6.1
  • Package manager: 5.6.1

Steps to reproduce

Our generation command

  struct GenerateCode: ParsableCommand {
    static var configuration = CommandConfiguration(
      commandName: "generate",
      abstract: "Generates swift code from your schema + your operations based on information set up in the `GenerateCode` command.")

    func run() throws {
      /// The root of the target for which you want to generate code.
      let targetRootURL = SourceRootURL
        .apollo.childFolderURL(folderName: "customer-ios/graphql")

      /// The URL where the generated schema files will be written to.
      let schemaModuleURL = SourceRootURL
        .apollo.childFolderURL(folderName: "customer-ios/graphql")

      // Make sure the folders exists before trying to generate code.
      try FileManager.default.apollo.createDirectoryIfNeeded(atPath: targetRootURL.path)
      try FileManager.default.apollo.createDirectoryIfNeeded(atPath: schemaModuleURL.path)

      // Create the Codegen configuration object. For all configuration parameters see: https://www.apollographql.com/docs/ios/api/ApolloCodegenLib/structs/ApolloCodegenConfiguration/
      let codegenConfiguration = ApolloCodegenConfiguration(
        schemaName: "GraphQLApi", input: ApolloCodegenConfiguration.FileInput(schemaPath: SchemaOutputURL.path, searchPaths: ["\(targetRootURL.path)/**/*.graphql"]),
        output: ApolloCodegenConfiguration.FileOutput(
          schemaTypes: ApolloCodegenConfiguration.SchemaTypesFileOutput(
            path: schemaModuleURL.path,
            moduleType: .embeddedInTarget(name: "customer-ios"))
        )
      )

      // Actually attempt to generate code.
      try ApolloCodegen.build(with: codegenConfiguration)
    }
  }
@calvincestari
Copy link
Member

Thanks for the bug report @kimdv. We'll take a look into this asap.

@calvincestari calvincestari self-assigned this Jun 8, 2022
@AnthonyMDev
Copy link
Contributor

Just also want to add my appreciation for these reports @kimdv! We'll get this sorted out soon!

@kimdv
Copy link
Contributor Author

kimdv commented Jun 15, 2022

@AnthonyMDev thanks for the work! 🎉

@calvincestari just tested with the latest alpha, and the warnings are gone 💪
Thanks!

@calvincestari
Copy link
Member

Good to hear @kimdv, thanks for circling back to let us know. Note that there are still some errors with the test mock generated code; we're working on those now to get them fixed in the next alpha.

@calvincestari
Copy link
Member

@kimdv there were some holdovers of this bug in other module configurations but with the merging of #2330 they should be fixed now. We plan to release 1.0.0-alpha.8 very soon and this will be included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants