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

JSONMatch array patch invalid tokens in Studio, sparse documentation #2474

Closed
fabien opened this issue May 4, 2021 · 1 comment · Fixed by #5063
Closed

JSONMatch array patch invalid tokens in Studio, sparse documentation #2474

fabien opened this issue May 4, 2021 · 1 comment · Fixed by #5063
Labels

Comments

@fabien
Copy link

fabien commented May 4, 2021

Describe the bug

Some tokens seem to be not implemented in Studio, while the backend actually handles them (eg. the update is performed, which is apparent after full browser reload of the document).

Also, the documentation is too sparse on what JSONMatch actually does, when to use it, how it compares to GROQ, and how to use it properly using the JS client to perform mutations. In particular, any examples of patch updates (set, inc, dec, ...) on array items are missing entirely.

The constraints mentioned here https://www.sanity.io/docs/json-match#9wMQqAol are also quite limiting, because most often you require intersection instead of union.

Steps to reproduce the behavior

I'm running this script using sanity exec:

client.patch('c3f54014-12cb-49f3-ba4c-734d3586382f', (p) =>
  p.set({
    [`variants[stock >= 20].stock`]: 20,
  })
);

Expected behavior

Studio should handle the update correctly.

Screenshots

image

Which versions of Sanity are you using?

@sanity/cli 2.10.0 (up to date)
@sanity/base 2.10.0 (up to date)
@sanity/components 2.2.6 (up to date)
@sanity/core 2.10.0 (up to date)
@sanity/default-layout 2.10.0 (up to date)
@sanity/default-login 2.8.0 (up to date)
@sanity/desk-tool 2.10.1 (up to date)
@sanity/vision 2.10.0 (up to date)

@fabien
Copy link
Author

fabien commented May 4, 2021

Related: #2421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants