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

MutableSelectionSet child objects missing selections #3437

Open
pixelmatrix opened this issue Sep 5, 2024 · 1 comment
Open

MutableSelectionSet child objects missing selections #3437

pixelmatrix opened this issue Sep 5, 2024 · 1 comment
Labels
bug Generally incorrect behavior needs investigation planned-next Slated to be included in the next release

Comments

@pixelmatrix
Copy link

Summary

I have a mutable fragment that has relationships to other objects, like this:

fragment MutableIssueFields on Issue @apollo_client_ios_localCacheMutation {
  id
  state {
    id
    name
  }
}

Codegen ends up creating MutableIssueFields and MutableIssueFields.State. The parent object MutableIssueFields has a __selections property as you'd expect, but MutableIssueFields.State does not.

I'm trying to change the value from one "state" to another using a local cache mutation. However, when I try to load the MutableIssueFields.State object from the cache, I get an empty object because the __selections field is empty.

I'm calling it like this:

store.withinReadWriteTransaction { tx in
  let newState = try tx.readObject(ofType: MutableIssueFields.State.self, withKey: "State:\(id)")
  try tx.updateObject(ofType: MutableIssueFields.self) { obj in
    obj.state = newState
  }
}

Is this something that should be supported? If not, is there a preferred way to update this relationship to another existing object in the cache?

Version

1.14.1

Steps to reproduce the behavior

  1. Create a fragment marked with @apollo_client_ios_localCacheMutation, that references some child object
  2. Populate cache with data that will fulfill the fragment
  3. Use a read write transaction to try to fetch the child object using readObject
  4. Observe the child object is returned with empty data

Logs

No response

Anything else?

No response

@pixelmatrix pixelmatrix added bug Generally incorrect behavior needs investigation labels Sep 5, 2024
@AnthonyMDev
Copy link
Contributor

No your code looks correct, and this should be supported. It seems like it's a bug that the MutableIssueFields.State has an empty __selections. That shouldn't be.

We'll need to see if we can reproduce this.

@AnthonyMDev AnthonyMDev added the planned-next Slated to be included in the next release label Nov 8, 2024
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 planned-next Slated to be included in the next release
Projects
None yet
Development

No branches or pull requests

2 participants