Open torjusb opened 8 months ago
Thanks for reporting this, I'm able to replicate it.
@stipsan I guess this is an applySourceDocuments concern?
As far as I can tell CSM will provide a mapping for values returned using a pt::text
function, but the mapping type is simply value
, and the mapping source will match exactly a mapping of the same field queried without pt::text
. So there is no obvious context from the CSM to indicate that the value should be returned from the result rather than the cached document.
I am also experiencing this issue - is there a workaround?
Thanks for reporting this, I'm able to replicate it.
@cody I guess this is an applySourceDocuments concern?
As far as I can tell CSM will provide a mapping for values returned using a
pt::text
function, but the mapping type is simplyvalue
, and the mapping source will match exactly a mapping of the same field queried withoutpt::text
. So there is no obvious context from the CSM to indicate that the value should be returned from the result rather than the cached document.
Howdy! Please ensure you’re tagging the correct Cody. I’m not involved with this one. Thanks!
Howdy! Please ensure you’re tagging the correct Cody. I’m not involved with this one. Thanks!
🤦 Sorry about that!
Hey, I am having the same issue using preview-kit in a Remix setup:
https://github.com/sanity-io/visual-editing/assets/630609/e9dd497b-ed67-471e-b233-f5fad6d4d953
Here’s a repository to reproduce the behavior shown in the video above. There’s also an open discussion on the Sanity Slack channel.
Describe the bug
When using
useQuery()
with a query that includes thept::text
function, theuseQuery
will seemingly ignore the function, and just return the full object. When trying to print the result in JSX, React will crash withObjects are not valid as a React child (found: object with keys {_key, _type, children, markDefs, style})
To Reproduce
Steps to reproduce the behavior:
.env.local
, addNEXT_PUBLIC_SANITY_PROJECT_ID
,NEXT_PUBLIC_SANITY_DATASET
andSANITY_API_READ_TOKEN
npm install && npm run dev
.body
text.Expected behavior
The post should preview correctly, showing the body text as plain text.
Which versions of Sanity are you using?
What operating system are you using?
MacOS Sonoma (14.0)
Which versions of Node.js / npm are you running?
v19.9.0
Additional context
GROQ query which will crash live preview: