sanity-io / assist

Sanity AI Assist: A plugin for Sanity Studio
MIT License
13 stars 5 forks source link

fix: add support for `sanity graphql deploy` #31

Closed stipsan closed 5 months ago

stipsan commented 5 months ago

Without this PR you get this error if you try to run sanity graphql deploy:

> sanity graphql deploy

✖ Generating GraphQL API: graphql/default

Error: Encountered anonymous inline object at index  for type/field SanityAssistInstruction/output. 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

This PR fixes it, testable using npm i @sanity/assist@canary --save-exact, and the AssistInstructionContext types are generated and available.

snorrees commented 5 months ago

Hmm, ideally we should not expose the sanity assist type in the graph QL api: the type is intentionally defined as 'object' and uses 'sanity.' prefix to not show up in structure.

I guess we could apply this change regardless, but I was under the impression that sanity. prefixed types where omitted from most surfaces.

stipsan commented 5 months ago

The graphql deploy command still requires objects to be declared on the top level to be able to parse the schema. Even if they ultimately don't get deployed. It's only the AI Context document type that ends up deployed, which makes sense as it also shows up in structureTool. Everything else is hidden just like in Structure