我想将images文档中的一个字段设置为 type 的数组[SanityImage]。我尝试将其设置为,type: 'image'但是当我查询该字段时,我得到类型是[SanityCollectionItemsImages]
该images字段位于对象 ( productVariant) 中,然后包含在主文档 ( ) 中,我的字段collection中有一个数组。productVariantsitems
在我的collection文档的 fields 数组中:
...
{
title: "Items",
name: "items",
type: "array",
of: [
{
title: "Item",
type: "productVariant",
},
],
},
...
productVariant类型对象:
export default {
title: "Product variant",
name: "productVariant",
type: "object",
fields: [
{
name: "images",
title: "Images",
type: "array",
of: [
{
type: "image",
options: {
hotspot: true,
},
},
],
},
...
我使用 GraphQL 的查询:
allSanityCollection {
edges {
node {
_id
title
description
items {
_key
title
images {
asset {
_ref
_id
fluid(maxHeight: 600) {
base64
aspectRatio
src
srcSet
srcWebp
srcSetWebp
sizes
}
}
}
}
}
}
}
当我单击imagesGraphiQL Web IDE 中的字段时:

使用 Sanity.io HTTP API 获取整个文档:
"images": [
{
"_key": "5605f5383975",
"_type": "image",
"asset": {
"_ref": "image-14f9b7688912499f187b7c20e57816b3cdf42c1e-4016x4688-jpg",
"_type": "reference"
}
},
...
我的问题是如何将我的模式中的字段类型设置为显式[SanityImage]而不是,[SanityCollectionItemsImages]为什么我会得到那种奇怪的类型?