Content Relationships and Slice Machine

Hi I managed to get my slices to work with content relationships but slice simulator isn't receiving this data so I can't preview data or get screenshots.

I have a testimonials slice that pulls in data from a testimonials custom type.

I am using Prismic with NextJS.

My homepage is coded like this.

import { createClient } from '../prismicio';
import { SliceZone } from '@prismicio/react';
import { components } from '../slices/index';

import Layout from '../components/Layout';

export default function Home({ layout, home }) {
	return (
		<Layout layout={layout}>
			<SliceZone
				slices={home.data.slices}
				components={components}
			/>
		</Layout>
	);
}

export async function getStaticProps({ params, previewData }) {
	const client = createClient({ previewData });

	const layout = await client.getSingle('layout');
	const home = await client.getSingle('homepage', {
		fetchLinks: 'testimonials.testimonial',
	});

	return {
		props: {
			layout,
			home,
		},
	};
}

I am pulling in data in my slice with

slice.primary.testimonialRelationships.data.testimonial

I works fine when I view page as a whole at localhost:3000 but when in slice simulator (even for other slices now) I'm getting this error.

TypeError: Cannot read properties of undefined (reading 'testimonial')

Hi Roy,

Mock data for content relationships is not possible in Slice Machine at the moment, the team are planning to work on this very soon. This is being tracked as a feature request here:

For now you will only be able to test this with Published content in your Prismic repository.

Thanks.

1 Like

Hi Phil,

what is the current status of this feature?
it's crucial feature for me as I can't do screenshot and test my slices via slicemachine.

Best
Mateusz

There has been no change in the release status of this feature. For now it's only possible to test with live content and add Custom screenshots.