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

Setter for local cache mutation is unavailable, mutate properties of fragment #3428

Closed
PSinha1202 opened this issue Aug 22, 2024 · 7 comments
Labels
bug Generally incorrect behavior needs investigation

Comments

@PSinha1202
Copy link

Summary

There seems to be related bug #3398 which was resolved before but when today when I run the Apollo tag 1.15.0 with Xcode 16 beta and swift 5, fragment annotated with @apollo_client_ios_localCacheMutation directive causes compile time error

Setter for ' is unavailable: mutate properties of the fragment instead.`

Can I get a confirmation if the issue still persist?

Version

1.15.0

Steps to reproduce the behavior

update Apollo to latest 1.15.0
Xcode 16 beta with swift 5
compile our codebase and found two errors and both related to same fragment those are annotated with @apollo_client_ios_localCacheMutation

Logs

No response

Anything else?

No response

@PSinha1202 PSinha1202 added bug Generally incorrect behavior needs investigation labels Aug 22, 2024
@AnthonyMDev
Copy link
Contributor

Hi @PSinha1202. Can you confirm that you have re-run the code generation with the latest version? This fix changes the generated models to remove the warning.

@PSinha1202
Copy link
Author

ahh I see, let me try that and confirm @AnthonyMDev

@PSinha1202
Copy link
Author

ok so tried the re-run code gen and I get into this error

Error: typeMismatch(ApolloCodegenLib.ApolloCodegenConfiguration.SelectionSetInitializers, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "options", intValue: nil), CodingKeys(stringValue: "selectionSetInitializers", intValue: nil)], debugDescription: "Unrecognized key found: localCacheMutations", underlyingError: nil))
Finished fetch + codegen

I tried deleting all models to re-run code gen but still seeing the above issue.

@AnthonyMDev
Copy link
Contributor

Oh, that's not great, but easy to fix. We removed the localCacheMutations config option for selectionSetInitializers. Because we are now just always generating initializers for local cache mutations. The default value had that included, so your config file is going to have that line included.

We should get a patch out that handles this situation gracefully but for now, you can remove that line from your codegen config JSON file and it should work.

@PSinha1202
Copy link
Author

PSinha1202 commented Aug 22, 2024

Sure will try, but as of now I have downgraded to 1.14.1 and re-ran the codegen and it seems to fix my original issue and I am able to compile my code. Will check the 1.15.0 or later version in couple of days.

@AnthonyMDev
Copy link
Contributor

Sounds good. This should be resolved. If you are still having issues, let us know and we can re-open the issue.

Copy link
Contributor

Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior needs investigation
Projects
None yet
Development

No branches or pull requests

2 participants