Creating a top-level schema for nested objects in GraphQL
2 replies
Last updated: Feb 19, 2023
A
Hi everyone! I am trying to use Graphql with my Sanity context, but im using groups for a page. And when i try to export the data to Graphql its telling me: Encountered anonymous inline object "group" for field/type "groups". To use this field with GraphQL you will need to create a top-level schema type for it.
– How should i do this? just create another file called groups? i understand groups it's only to separate by tabs and organize the content input better.. not sure how to apply create a top schema for something like this. Thanks for your help!
Feb 18, 2023, 1:08 PM
R
Hi
user E
, This is a common wall that you’ll hit periodically with GraphQL.
Create an object schema anytime there are nested objects fields within another object. This joists it up to a top-level object in GraphQL.
When I work in GraphQL, I create a single object file called
refObjects
. I keep the entire projects reference objects in it. Here’s an example of my