Skip to content

Conversation

@AnthonyMDev
Copy link
Contributor

Fixes apollographql/apollo-ios#3590

When models use an internal access modifier they should not include @_spi notations. These are only relevant for public properties and will cause a compilation error if included.

@apollo-librarian
Copy link

apollo-librarian bot commented Oct 8, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: fedef1af120d689e0bb8918a
Build Logs: View logs

@netlify
Copy link

netlify bot commented Oct 8, 2025

Deploy Preview for apollo-ios-docc canceled.

Name Link
🔨 Latest commit 8a8a60f
🔍 Latest deploy log https://app.netlify.com/projects/apollo-ios-docc/deploys/68e81835ac8c4f000883c94d

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes @_spi annotations from internal models to fix compilation errors. When models use an internal access modifier, SPI annotations should not be included as they are only valid for public declarations.

Key changes:

  • Created a new AccessControlRenderer class to handle both access control modifiers and SPI annotations
  • Replaced direct access control string generation with centralized renderer throughout templates
  • Updated test configurations and expected outputs to match internal access without SPI annotations

Reviewed Changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
AccessControlRenderer.swift New centralized class for rendering access control with conditional SPI support
TemplateRenderer.swift Refactored to use AccessControlRenderer instead of direct string generation
SelectionSetTemplate.swift Updated to use AccessControlRenderer for consistent access control rendering
Various template files Updated to use new AccessControlRenderer pattern
Test configuration files Updated configurations and expected test outputs

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +23 to +27
init(
operation: IR.Operation,
operationIdentifier: String?,
config: ApolloCodegen.ConfigurationContext,
) {
Copy link

Copilot AI Oct 9, 2025

Choose a reason for hiding this comment

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

Missing parameter documentation for the new initializer. Consider adding documentation comments to explain the parameters and purpose of this initializer.

Copilot uses AI. Check for mistakes.
@@ -1,13 +0,0 @@
// @generated
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason these files were removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They should never have been checked in in the first place! We aren't customizing our custom scalars. So we actually, want the codegen to regenerate them and test that the newly generated files are correct and still compile.

fileprivate extension ApolloCodegenConfiguration.AccessModifier {
var swiftString: String {
switch self {
case .public: return "public " // there should be no spaces in these strings
Copy link
Member

Choose a reason for hiding this comment

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

The space after "public" is the same as the code was in TemplateRenderer so I assume it had changed over time from the comment, but we should just remove the comment now since it's not applicable.

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, nice cleanup to centralize the access control rendered.

@AnthonyMDev AnthonyMDev merged commit 7ad3dc8 into main Oct 9, 2025
11 of 13 checks passed
@AnthonyMDev AnthonyMDev deleted the no-spi-on-internal-models branch October 9, 2025 20:17
@apollo-bot2
Copy link
Contributor

Detected SAST Vulnerabilities

BobaFetters pushed a commit that referenced this pull request Oct 9, 2025
BobaFetters pushed a commit to apollographql/apollo-ios-codegen that referenced this pull request Oct 9, 2025
BobaFetters pushed a commit that referenced this pull request Oct 9, 2025
a4e90970f Remove SPI from internal models (#796)

git-subtree-dir: apollo-ios-codegen
git-subtree-split: a4e90970fa0a1117dd505eaabb7f8265af49fe8f
BobaFetters pushed a commit that referenced this pull request Oct 9, 2025
git-subtree-dir: apollo-ios-codegen
git-subtree-mainline: 1aaf87e
git-subtree-split: a4e90970fa0a1117dd505eaabb7f8265af49fe8f
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.

Apollo v2.0 | Codegen CLI compile issue: '@_spi' properties need to be public

4 participants