Reputation: 25
I'm trying to learn Sanity and I'm stuck in trying to fetch from an array of an objects with multiple strings.
Thank you so much!
Schema:
{
name: "testArray",
title: "Test Array",
type: "array",
of: [
{
name: "field",
type: "object",
title: "Field",
fields: [
{
name: "firstField",
type: "string",
title: "First String"
},
{
name: "secondField",
type: "string",
title: "Second String"
},
]
}
]
},
Upvotes: 0
Views: 1316
Reputation: 1632
->
is a de-referencing operator. We use it only if any of our field is referencing to some document in the current dataset, and we are asking sanity to fetch the referenced document data for us.
In your schema, the testArray
field is not referencing to any document, so I dont think you should use ->
.
I believe the below code should work fine:
*[_type == "<schema_name>"] {
title,
testArray
}
Upvotes: 0