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

Disable Fragment Field Merging #431

Merged
merged 36 commits into from
Aug 14, 2024

Conversation

AnthonyMDev
Copy link
Contributor

@AnthonyMDev AnthonyMDev commented Jul 16, 2024

This PR is a working implementation of the feature to allow disabling of field merging in generated models. Previous PRs were corrupted during rebasing and will be closed. This unified PR contains the entire feature.

Field merging configuration is implemented as an experimental feature currently. This needs ample testing in production before being considered stable.

Functionality

  • Adds FieldMerging option to ApolloCodegenConfiguration
  • Implements logic for respecting merging strategy while traversing EntitySelectionTree
  • Updates SelectionSetTemplate to properly generate based on field merging configuration
  • Validates that selectionSetInitializers and fieldMerging are not used together.

Testing:

This PR is fully unit tested.
Manual testing can be done on the AnimalKingdomAPI, GitHubAPI, and StarWarsAPI by changing the config values in the SwiftScripts/Codegen and then running swift run Codegen. All packages compile correctly with any combination of field merging values.

Future Work

Possible future iterations include:

  • Allowing field merging to be configured on a per definition or per selection set basis.
  • This feature does not work with selectionSetInitializers. I currently believe these to be fundamentally incompatible. If a means of making these features compatible can be identified, we should implement it.

…tringly typed Codable usage for JSON encoding
…tringly typed Codable usage for JSON encoding
Copy link

netlify bot commented Jul 16, 2024

Deploy Preview for eclectic-pie-88a2ba canceled.

Name Link
🔨 Latest commit fce9e23
🔍 Latest deploy log https://app.netlify.com/sites/eclectic-pie-88a2ba/deploys/66bba7e09837ad000837d364

Copy link

netlify bot commented Jul 16, 2024

Deploy Preview for apollo-ios-docc ready!

Name Link
🔨 Latest commit fce9e23
🔍 Latest deploy log https://app.netlify.com/sites/apollo-ios-docc/deploys/66bba7e044499900084f1900
😎 Deploy Preview https://deploy-preview-431--apollo-ios-docc.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.

…_fragment_reference_fields

# Conflicts:
#	apollo-ios-codegen/Sources/GraphQLCompiler/ApolloCodegenFrontendBundle.swift
@AnthonyMDev AnthonyMDev marked this pull request as draft July 29, 2024 21:18
@AnthonyMDev AnthonyMDev marked this pull request as ready for review August 13, 2024 18:35
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.

Tests look good, let's get this merged!

@AnthonyMDev AnthonyMDev merged commit 9109433 into main Aug 14, 2024
37 checks passed
@AnthonyMDev AnthonyMDev deleted the Field_Merging_7_x_fix_fragment_reference_fields branch August 14, 2024 18:27
BobaFetters pushed a commit that referenced this pull request Aug 14, 2024
BobaFetters pushed a commit to apollographql/apollo-ios-codegen that referenced this pull request Aug 14, 2024
BobaFetters pushed a commit that referenced this pull request Aug 14, 2024
199d6157 Disable Fragment Field Merging (#431)

git-subtree-dir: apollo-ios-codegen
git-subtree-split: 199d615764613523ed93f87f1f86c2c2675531fd
BobaFetters pushed a commit that referenced this pull request Aug 14, 2024
git-subtree-dir: apollo-ios-codegen
git-subtree-mainline: cbe61c9
git-subtree-split: 199d615764613523ed93f87f1f86c2c2675531fd
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.

2 participants