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

Cache corruption issue with useQuery #7

Closed
iankberry opened this issue Jul 29, 2021 · 2 comments
Closed

Cache corruption issue with useQuery #7

iankberry opened this issue Jul 29, 2021 · 2 comments

Comments

@iankberry
Copy link

I've got another strange issue where the cached data coming back from useQuery is slightly corrupted. It's the same query that I was referencing in #6.

Here is what the data looks like when using the stock @apollo/client version of useQuery:

{
  "selectedEnergyEvent": {
    "__typename": "EnergyEvent",
    "id": "8357862188871433499",
    "time": "2021-07-28T18:39:08-04:00",
    "startTime": "2021-07-28T14:34:31-04:00",
    "endTime": "2021-07-28T18:39:08-04:00",
    "energyType": "DRAIN",
    "algorithm": "WORK_TIME",
    "algorithmData": null,
    "context": [
      {
        "__typename": "EnergyActivityContext",
        "contextType": "ACTIVITY",
        "activity": {
          "__typename": "ActivitySlice",
          "id": "6100042703173699744",
          "providerId": "504326868638495413",
          "providerType": "GOOGLE",
          "providerGroupName": "Default",
          "startTime": "2021-07-28T14:34:31-04:00",
          "endTime": "2021-07-28T14:38:32-04:00",
          "activityType": "APP",
          "activityGroup": "iTerm",
          "activityCount": 2,
          "audience": "INDIVIDUAL",
          "categories": [
            "WORKGROUP_ACCOUNT"
          ],
          "participants": [],
          "energyType": "NONE",
          "vendorUrl": null
        }
      }
    ]
  }
}

And the exact same query with apollo-augmented-hooks:

{
  "selectedEnergyEvent": {
    "id": "8357862188871433499",
    "__typename": "EnergyEvent",
    "time": "2021-07-28T18:39:08-04:00",
    "startTime": "2021-07-28T14:34:31-04:00",
    "endTime": "2021-07-28T18:39:08-04:00",
    "energyType": "DRAIN",
    "algorithm": "WORK_TIME",
    "algorithmData": null,
    "context": [
      {
        "__typename": "EnergyActivityContext",
        "contextType": "ACTIVITY",
        "activity": {
          "id": "6100042703173699744",
          "__typename": "ActivitySlice",
          "providerId": "504326868638495413",
          "providerType": "GOOGLE",
          "providerGroupName": "Default",
          "startTime": "2021-07-28T14:34:31-04:00",
          "endTime": "2021-07-28T14:38:32-04:00",
          "activityType": "APP",
          "activityGroup": "iTerm",
          "activityCount": 2,
          "audience": "INDIVIDUAL",
          "categories": [
            {
              "0": "W",
              "1": "O",
              "2": "R",
              "3": "K",
              "4": "G",
              "5": "R",
              "6": "O",
              "7": "U",
              "8": "P",
              "9": "_",
              "10": "A",
              "11": "C",
              "12": "C",
              "13": "O",
              "14": "U",
              "15": "N",
              "16": "T"
            }
          ],
          "participants": [],
          "energyType": "NONE",
          "vendorUrl": null
        }
      }
    ]
  }
}

Possible relevant, I am using the apollo-cache-persist library to persist my Apollo cache to localstorage. If I look at the data in localstorage directly, it is correctly formatted though.

If I had to guess, it looks like a possible issue with the spread operator on a nested array but you'd know better than me :-)

@mindnektar
Copy link
Owner

Hey, I just fixed this in v1.11.4 - I happened to stumble across the very thing in one of my projects today. Thanks again for helping me make this library as good as possible!

@iankberry
Copy link
Author

Worked like a charm. Thanks again!

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

No branches or pull requests

2 participants