Reputation: 848
I have a recipes.js document that has a tag field:
{
name: 'tags',
title: 'Tags',
type: 'array',
of: [{ type: 'reference', to: { type: 'tags' } }],
options: {
layout: 'tags',
},
},
it references another document called tags.js:
export default {
name: 'tags',
type: 'document',
title: 'Tags',
fields: [
{
name: 'title',
title: 'Title',
type: 'string',
},
],
};
I am trying to add the tags to each recipe as an array of strings in graphql. such as:
"tags": ['dinner', 'lunch', 'ribs']
but instead, I get an array of objects:
"tags": [
{
"title": "breakfast"
},
{
"title": "pancakes"
},
{
"title": "food"
}
]
How can I tell sanity all I want is each one to be added in as a string so it is an array of strings and not objects.
Upvotes: 0
Views: 2328
Reputation: 3365
Sanity's GraphQL API does not support transforming the data structure into something else. If you want to do that, you will have to use GROQ.
Upvotes: 1