I'm having a issue with deploying graphql query something about top level schema error.
I can see the issue! You're getting this error because you have a nested image type inside your logoImage object, and the image type itself has fields (the alt text). This creates what GraphQL sees as an "anonymous inline" structure that's too deeply nested.
The problem is in your logoImage.js schema - you have an object type that contains an image field with additional fields. GraphQL needs flatter structures.
Here's how to fix it:
Option 1: Simplify by using the image type directly (Recommended)
Instead of wrapping the image in an object, just use the image type with its fields directly in your homepage.js:
// In homepage.js
{
name: "logoImageWhite",
type: "image",
title: "Logo White Image",
fields: [
{
name: "alt",
type: "string",
title: "Alt Tag",
options: {
isHighlighted: true,
},
},
],
},
{
name: "logoImageColor",
type: "image",
title: "Logo Color Image",
fields: [
{
name: "alt",
type: "string",
title: "Alt Tag",
options: {
isHighlighted: true,
},
},
],
}Option 2: Flatten your logoImage object
If you need the object wrapper for other reasons, flatten it by removing the nested image and putting the fields at the object level:
// logoImage.js
export default {
title: "Logo Image",
type: "object",
name: "logoImage",
fields: [
{
name: "asset",
type: "reference",
to: [{type: "sanity.imageAsset"}],
title: "Image Asset",
},
{
name: "alt",
type: "string",
title: "Alt Tag",
},
],
};The core issue is that GraphQL can't handle the nesting pattern of object β image β fields. As explained in the Sanity documentation on object types and this answer about GraphQL inline images, you need to avoid deeply nested anonymous structures when using GraphQL.
After making these changes, redeploy your GraphQL schema and the error should be resolved!
Show original thread11 replies
Sanity β Build the way you think, not the way your CMS thinks
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.