All questions

If I fetch Strapi content over GraphQL, does Croct need to hook into that query?

Asked by Priyanka Rao on

PRPriyanka Rao

Our app pulls everything from Strapi through the GraphQL plugin. Before I wire Croct in I want to get the mental model right. Does Croct need to hook into that GraphQL query somehow, sitting in front of it or replacing it, or does it work another way?

I am trying to understand how the two relate before I change any of our fetching behaviour.

Was this helpful?

2 answers

Hhannah_cro

Croct does not intercept or replace your Strapi GraphQL queries. You keep fetching your base content exactly the way you do now, the GraphQL plugin stays untouched.

The way it actually relates: the integration maps your Strapi components and dynamic zones to Croct slots, and Croct serves the right variant for a given slot. Your Strapi content stays as the default fallback, so if Croct returns nothing for a slot the page still renders your base content. Two separate layers. Your query is the content, Croct is the personalization on top of it.

Was this helpful?
DFDiego F

The part that made it click for me was realising you request the slot content separately from the GraphQL fetch, then merge it where that block renders. Server-side you call fetchContent for the slot, in React you use the useContent hook, and you drop the result into the same props your GraphQL data already feeds. So my hero component still gets its base fields from the Strapi query and just takes the personalized overrides from the slot when there is one. Nothing about the GraphQL layer changed.

Was this helpful?
PRPriyanka Rao

That clears up the mental model, thank you. Two layers, base content from my query, Croct merged in at render. I can work with that.

Still have questions?