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

feature: Adding codegen config support for spm module type versions #539

Merged
merged 10 commits into from
Nov 27, 2024

Conversation

BobaFetters
Copy link
Member

@BobaFetters BobaFetters commented Nov 15, 2024

Adding new codegen config options for supplying a version to the SPM module type to allow for pointing to specific branches or local versions.

Closes apollographql/apollo-ios#3017

Setup codegen config options and tests for new spm module type version
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Nov 15, 2024

✅ Docs Preview Ready

Configuration
{
  "repoOverrides": {
    "apollographql/apollo-ios-dev@main": {
      "remote": {
        "owner": "apollographql",
        "repo": "apollo-ios-dev",
        "branch": "feature/package-config-3017"
      }
    }
  }
}
Name Link

Commit

bb90255

Preview

https://www.apollographql.com/docs/deploy-preview/18faba0733cc22d69279

Build ID

18faba0733cc22d69279

File Changes

0 new, 15 changed, 0 removed
* (developer-tools)/ios/(latest)/index.mdx
* (developer-tools)/ios/(latest)/code-generation/codegen-configuration.mdx
* (developer-tools)/ios/(latest)/fetching/queries.mdx
* graphos/reference/router/telemetry/instrumentation/standard-instruments.mdx
* graphos/reference/router/rhai.mdx
* graphos/reference/router/errors.mdx
* graphos/reference/router/configuration.mdx
* graphos/routing/customization/coprocessor.mdx
* graphos/routing/customization/overview.mdx
* graphos/routing/observability/subgraph-error-inclusion.mdx
* graphos/routing/observability/client-id-enforcement.mdx
* graphos/routing/performance/caching/entity.mdx
* graphos/routing/security/authorization.mdx
* graphos/routing/security/request-limits.mdx
* graphos/routing/self-hosted/containerization/index.mdx

Pages

15


15 pages published. Build will be available for 30 days.

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for apollo-ios-docc canceled.

Name Link
🔨 Latest commit bb90255
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docc/deploys/67476639fb51520008257e78

Copy link

netlify bot commented Nov 15, 2024

Deploy Preview for eclectic-pie-88a2ba ready!

Name Link
🔨 Latest commit bb90255
🔍 Latest deploy log https://app.netlify.com/sites/eclectic-pie-88a2ba/deploys/6747663999d0f50008d32dbf
😎 Deploy Preview https://deploy-preview-539--eclectic-pie-88a2ba.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@calvincestari calvincestari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on the case naming but otherwise I think this looks good so far. Still the swift package manager module template changes to implement right?

Finished implementation in SchemaModuleTemplate for new spm module type versions
@BobaFetters BobaFetters marked this pull request as ready for review November 16, 2024 04:36
Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this Zach! A couple things I'd like us to consider here before merging this.

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing this again got me thinking. Is it worth adding an option for users to point their Apollo dependency to their own fork? Right now you can point to a branch or commit hash, but it's still only on the url https://github.com/apollographql/apollo-ios.git.

@BobaFetters @calvincestari do you think that's worth doing at this time?

@calvincestari
Copy link
Member

Reviewing this again got me thinking. Is it worth adding an option for users to point their Apollo dependency to their own fork? Right now you can point to a branch or commit hash, but it's still only on the url https://github.com/apollographql/apollo-ios.git.

@BobaFetters @calvincestari do you think that's worth doing at this time?

I don't see any reason why we'd want to restrict it to https://github.com/apollographql/apollo-ios.git. Unless it's a strategic choice but that seems incongruous with OSS.

@calvincestari
Copy link
Member

I just had the thought that maybe allowing something other than https://github.com/apollographql/apollo-ios.git makes the CLI version checking less useful BUT is this whole PR change doing that? How do we now ensure generated code compatibility with the runtime used by that generated code?

@AnthonyMDev
Copy link
Contributor

I just had the thought that maybe allowing something other than https://github.com/apollographql/apollo-ios.git makes the CLI version checking less useful BUT is this whole PR change doing that? How do we now ensure generated code compatibility with the runtime used by that generated code?

Likely you're just making some changes in your fork that don't affect codegen compatibility, but yeah any manual dependency here means you may generate incompatible code. That's something the user needs to accept and deal with on their own. If you're using anything but the default package version, we shouldn't even be using the version checker at all actually.

The version checker isn't foolproof right now anyways. It only runs on the CLI, not Swift Scripts, and if it can't find a package.resolved file, it won't run at all. But worse case, you generate code that doesn't compile properly and you know it when you try to build. This is just to attempt to detect that early and give you a clear error message.

But I'm actually wondering if we should move this into ApolloCodegenLib now. We are currently only running it when using CLI, but could probably run it while using Swift Scripts also. Doesn't need to be in this PR if we decide to do so.

@calvincestari
Copy link
Member

But I'm actually wondering if we should move this into ApolloCodegenLib now. We are currently only running it when using CLI, but could probably run it while using Swift Scripts also. Doesn't need to be in this PR if we decide to do so.

Yes we probably should, and in a separate PR.

@BobaFetters
Copy link
Member Author

Reviewing this again got me thinking. Is it worth adding an option for users to point their Apollo dependency to their own fork? Right now you can point to a branch or commit hash, but it's still only on the url https://github.com/apollographql/apollo-ios.git.

@BobaFetters @calvincestari do you think that's worth doing at this time?

I don't see a reason not to add that, I guess maybe add a url associated value that defaults to apollo-ios to the existing cases? Although we dont currently have a case that supports version numbers since for Apollo we want it to match the codegen version, so may need a new case that can support the from and exact versions.

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this API now. I think the changes we made are great and this is the right way forward now. Great work @BobaFetters!

I've got a couple minor suggestions, and we're still waiting on documentation. But the core of this is looking good!

@@ -106,7 +106,7 @@ The properties to configure `output` are:
"output": {
"schemaTypes": {
"moduleType": {
"swiftPackageManager": {}
"swiftPackage": {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's long bugged me that we had swiftPackageManager as a ModuleType option and swiftPackage as a TestMocks option; I'm happy these are more similar now. 😄

docs/source/code-generation/codegen-configuration.mdx Outdated Show resolved Hide resolved
Copy link
Member

@calvincestari calvincestari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, nice work!

@@ -283,7 +283,12 @@ public struct ApolloCodegenConfiguration: Codable, Equatable {
case embeddedInTarget(name: String, accessModifier: AccessModifier = .internal)
/// Generates a `Package.swift` file that is suitable for linking the generated schema types
/// files to your project using Swift Package Manager.
/// Attention: This case has been deprecated, use .swiftPackage(apolloSDKVersion:) case instead.
case swiftPackageManager
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we eventually remove these cases if we can't signal ahead of time with the deprecation attribute? Removing them in a future major version seems impossible if we're relying on people reading the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think it just has to be removed in a major version and noted in release notes. Not much else to do without adding the actual deprecation warning.

@BobaFetters BobaFetters merged commit 58adaf3 into main Nov 27, 2024
34 checks passed
@BobaFetters BobaFetters deleted the feature/package-config-3017 branch November 27, 2024 22:54
BobaFetters pushed a commit that referenced this pull request Nov 27, 2024
…for spm module type versions

git-subtree-dir: apollo-ios
git-subtree-mainline: c528c4d
git-subtree-split: 38eef8f5109fd9677ce9a709f2632b8783536ac3
BobaFetters pushed a commit that referenced this pull request Nov 27, 2024
cfe27487 feature: Adding codegen config support for spm module type versions (#539)

git-subtree-dir: apollo-ios-codegen
git-subtree-split: cfe274876fa5e45b4bebef97beae278331681fd1
BobaFetters pushed a commit that referenced this pull request Nov 27, 2024
…support for spm module type versions

git-subtree-dir: apollo-ios-codegen
git-subtree-mainline: dbf486f
git-subtree-split: cfe274876fa5e45b4bebef97beae278331681fd1
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

Successfully merging this pull request may close these issues.

Add configuration for generating Package.swift tied to pre-release of Apollo library
4 participants