Gatsby v3 & Prismic v4 - upgrading -- dataRaw vs data

Hi there!

Hope you are all doing well.

We are upgrading to prismic V4 (for now) and we're running into some stuff. We are able to fix all of them however, it seems to be a lot of work (which is fine, IF there is no other way).

So, here's the thing. I noticed that when using the preview option from Prismic, it returns the data-object, and this does not work when your pages are using the dataRaw query. In the previous version, this did work out of the box. Did this change? (couldn't find this in the migration guide)

Additionally, a structuredText field (when using data) returns { text: "...", raw: [...], html: "..." }. When using dataRaw, you automatically get the raw. If I can't get around using data, is it possible to automagically get the raw for structuredText?

I hope I missed a configuration somewhere. :man_shrugging:

Let me know if additionally information is required.

Thank you in advance.

Best regards,

Jens

Hello @jens, welcome to the Community!

We just published an update in both the source and preview plugins with a fix to accept the dataRaw field in preview mode. The fix is only available for the latest version of V5.

  • gatsby-source-prismic : v5.2.2
  • gatsby-plugin-prismic-previews : v5.2.1

You can update your dependencies now to see the update.

Also. We don't recommend using dataRaw. Instead, you can call each field directly in data. Then for Rich Text fields you'll have three options text, raw and richtext. You should always use richtext to facilitate the formatting options when rendering the field on the front-end.

Hello Pau,

Thank you for your reply.

Is the fix also in v4.x of prismic? I can't upgrade to Prismic v5, because we're on Gatsby v3.x, right?

Also, when not using dataRaw, wouldn't the graphql (page) queries be enormous when you have multiple (shared) slices where all slices have 3+ fields?

Thank you again.

Best regards,

Jens

Sorry, I forgot to include that. No, the fix is only available for the latest version of V5.
For the Slice queries, I can recommend you separate them using fragments.

Thank you for your assistance Pau.

Anytime! Please let us know if you need help with anything else.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.