Data

WP GraphQL

Since we can’t determine the post type of pages vs posts by URI (due to how the permalinks are structured for those) we need to refactor to query all pages and post types like this.

Query by URI

This greatly simplifies how we’re handling routing since it will eliminate the need for subdirectories under the /frontend/pages path. With that in place we can simply dynamically render the correct single-item template (post/page/product/promotion/location, etc.) based on the post type of the node that’s returned.

Real Data

We can pull JSON data from Sitefinity sites like this.

Connect to Dev Database

You can connect to the demo site's database to work with large data sets to save time. Just make the backend localhost url the same as the dev site url in the constants.ts file.

simply make both of these variables match in order to work with demo site data in your local environment

Utilize the Wordpress Rest API

we can check block attributes here

Use The Dev Site Database

You can switch to the dev db to work with some actual data on the frontend. Just be sure not to alter it in any way. For alterations, you can export the data from WPAllImport

Block Attributes

circle-info

WP sends attributes as an array instead of object when none are set

Product Image Query Ideas

Example GraphQL Query for Image SrcSet

Rest API

this is a nice resource for Rest API routes

Embedded Image Fields

By default, posts come from the JSON API with only the ID of a featured image. But, there are embedded fields that can be utilized to get the image data.

Here we are getting an array of posts from the WP database using getEntityRecords. The third argument allows us to add options. When we set _embed to true, we get the extended data that we need to display images on the frontend.

This is what the image data looks like in a loop over that array of posts when called from the frontend component.

Manually Revalidate Cache

Paste this curl request into Insomniaarrow-up-right to manually revalidate cache.

Last updated