
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can see the issue in your code! There are a couple of problems causing null values:
1. Typo in field name: refrence vs refrences
In your schema, you defined the field as refrences (with an 'e'), but in your GROQ query you're requesting refrence (without the 'e'). This mismatch means you're querying for a field that doesn't exist, so it returns null.
2. Missing publishedAt in your query
You have a publishedAt field in your schema (which is your date field), but you're not requesting it in your GROQ query. You're only fetching _createdAt and _updatedAt.
Here's your corrected query:
const data = await client.fetch(`*[_type == "answerQuestion" && slug.current == "${context.query.slug}"]{
title,
slug,
mainImage{
asset->{
url
}
},
categories[]->{
title
},
author->{
name
},
body,
refrences, // Fixed spelling to match schema
publishedAt, // Added the date field from your schema
askedby, // You might want this too
videoURL, // And this
_createdAt,
_updatedAt
}`);Additional recommendations:
const data = await client.fetch(
`*[_type == "answerQuestion" && slug.current == $slug]{
title,
slug,
// ... rest of fields
}`,
{ slug: context.query.slug }
);Check your Studio - make sure you've actually published the documents with values in those fields. If you're fetching with the default published perspective (as of API version 2025-02-19), only published documents with published field values will appear.
Verify the author reference exists - if the author field is null, make sure you've actually selected an author document in the Studio and that the author document itself exists and is published.
The typo in the field name is almost certainly your main issue. Fix that spelling mismatch and you should see your values coming through!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store