apollographql / apollo-ios

📱  A strongly-typed, caching GraphQL client for iOS, written in Swift.
https://www.apollographql.com/docs/ios/
MIT License
3.86k stars 714 forks source link

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

Closed PSinha1202 closed 2 weeks ago

PSinha1202 commented 3 weeks ago

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

AnthonyMDev commented 3 weeks ago

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 commented 3 weeks ago

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

PSinha1202 commented 3 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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 commented 2 weeks ago

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

github-actions[bot] commented 2 weeks ago

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.