ndimatteo / HULL

💀 Headless Shopify Starter – powered by Next.js + Sanity.io
https://hull.dev
MIT License
1.36k stars 167 forks source link

Encountered anonymous inline object #102

Closed darisi closed 2 years ago

darisi commented 2 years ago

When I run "sanity graphql deploy" I get this error:

Error: Encountered anonymous inline image at index 1 for type/field Hero/content. To use this type with GraphQL you will need to create a top-level schema type for it. See https://docs.sanity.io/help/schema-lift-anonymous-object-type

And after checking shemas/modules/hero.js it seems to be a problem with this part:

{ title: 'Overlay Content', name: 'content', type: 'complexPortableText' },

I checked that field and nothing really stands out that there so I removed it from hero.js but then this error popped up:

Error: Encountered anonymous inline object "photos" for field/type "Hero". To use this field with GraphQL you will need to create a top-level schema type for it. See https://docs.sanity.io/help/schema-lift-anonymous-object-type

The sanity docs don't really make sense in this case as well as these are already objects with unique names.

All of these use the "customImage()" though but not sure why it would break there.

ndimatteo commented 2 years ago

Hey there @darisi! HULL doesn't utilize the GraphQL API feature for Sanity, so there are likely incompatibilities with the schema markup. Sanity requires strict schema conventions if you are wanting to deploy GraphQL APIs for your project.

darisi commented 2 years ago

Hm... strange as this error popped up for the hull studio schema. I'm adding new fields to sanity (blog posts) but not sure if I missed a step anywhere. Does hull push the schemas to sanity in a different way?

ndimatteo commented 2 years ago

@darisi because deploying GraphQL API's (using the Sanity CLI) requires strict schema conventions, there are a handful of things within the HULL schema that will break these requirements. Things like this, for example, are not following the conventions needed to deploy GraphQL.

There is no "pushing" with the schemas, they are meant to work with deploying studios (either in a custom environment or the sanity-hosted way). The only reason you'd want to deploy GraphQL APIs is if you are planning to use GraphQL for some reason.

This is not needed to successfully run HULL though, you can simply use GROQ and the built-in Vision tool to test queries.

I hope that helps, but let me know if I'm missing something with your question!