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

Merge warnings reported for JSONObject custom scalar #7071

Closed
vigie opened this issue Sep 24, 2020 · 2 comments
Closed

Merge warnings reported for JSONObject custom scalar #7071

vigie opened this issue Sep 24, 2020 · 2 comments
Assignees
Milestone

Comments

@vigie
Copy link

vigie commented Sep 24, 2020

Intended outcome:
My understanding is that all scalar values (custom or otherwise) should be treated opaquely and replaced when updating. Such updates should not trigger a data loss merge warning.

Actual outcome:
When merging objects containing fields of custom scalar type JSONObject, merge warning are generated in the console for these fields.

How to reproduce the issue:
Include JSONObject custom scalar into your schema and resolver map and use it in a type definition

scalar JSONObject

type Deployment {
   id: ID!
   state: JSONObject
}

execute a query to fetch an object that uses JSONObject, then update the data in the cache so the merge algorithm runs.

query DeploymentQuery($id: ID) {
    deployment(id: $id)  {
        id
        state
    }
}

Notice that when a deployment object that has a different value for state is being merged, you see warnings in the console about potential data loss for state field.

Versions

  System:
    OS: macOS 10.15.6
  Binaries:
    Node: 12.18.2 - ~/.nvm/versions/node/v12.18.2/bin/node
    npm: 6.14.5 - ~/.nvm/versions/node/v12.18.2/bin/npm
  Browsers:
    Chrome: 85.0.4183.121
    Firefox: 79.0
    Safari: 14.0
  npmPackages:
    @apollo/client: ^3.2.0 => 3.2.0
    apollo-angular: ^2.0.3 => 2.0.4
@benjamn benjamn self-assigned this Sep 24, 2020
benjamn added a commit that referenced this issue Sep 25, 2020
While it is possible to write a field merge function that handles updates
for scalar field values, we should treat scalar data as opaque by default,
without displaying "Cache data may be lost..." warnings that nudge the
developer to write an unnecessary merge function.

None: because this code is inside of a process.env.NODE_ENV block, it will
not be executed or bundled in production.

Should fix #7071.
benjamn added a commit that referenced this issue Sep 25, 2020
While it is possible to write a field merge function that handles updates
for scalar field values, we should treat scalar data as opaque by default,
without displaying "Cache data may be lost..." warnings that nudge the
developer to write an unnecessary merge function.

None: because this code is inside of a process.env.NODE_ENV block, it will
not be executed or bundled in production.

Should fix #7071.
@benjamn benjamn added this to the Post 3.0 milestone Sep 25, 2020
@benjamn
Copy link
Member

benjamn commented Sep 25, 2020

@vigie This should be fixed in @apollo/client@3.3.0-beta.5 (which includes #7075).

To be clear, this means you shouldn't need to configure JSONObject scalar fields with merge: false to prevent warnings, because there shouldn't be any warnings when updating scalar fields.

@vigie
Copy link
Author

vigie commented Sep 28, 2020

Thanks for the quick response @benjamn, I can confirm the issue appears to be fixed in 3.3.0-beta.5 👍

@vigie vigie closed this as completed Sep 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants