Unable to deploy schema field with ref and object array
See original GitHub issueWhen trying to create an array field of objects along with references to that same object the schema will not deploy.
Doing this works fine in the editor UI. It seems like a common case, so perhaps I’m missing something?
Error
Error: Found duplicate type names: Objective
at ~/ROOT/studio/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:156:31
at Generator.throw (<anonymous>)
at asyncGeneratorStep (~/ROOT/studio/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:7:103)
at _throw (~/ROOT/studio/node_modules/@sanity/core/lib/actions/graphql/deployApiAction.js:9:291)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Schema example causing the error
{
name: "objectives",
type: "array",
title: "Objectives",
of: [
{ type: "reference", to: { type: "objective" } },
{ type: "objective" },
],
},
Screenshot of schema field in editor UI

Sanity version: 2.7.4
Node version: 16
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Unable to define array items by $ref according to draft4 #749
I have a problem with define array item by $ref. Using Newtonsoft Json Schema I can write this code: { "title": "JSON Schema...
Read more >Mongoose save an array of objects in Ref schema
The children field in the parent is expecting an arrays of ObjectIds but you are passing it an arrays of objects that do...
Read more >API Reference: ApolloServer - Apollo GraphQL Docs
A map of functions that populate data for individual schema fields. Can also be an array of multiple maps that are merged. While...
Read more >Realm schema for different object types in array - MongoDB
I am trying to configure a Realm schema and Realm GraphQL (and later Sync) to support data where an array of objects can...
Read more >array — Understanding JSON Schema 2020-12 documentation
In JSON, each element in an array may be of a different type. Language-specific info: Python; Ruby ... Each of these fields will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, thanks for confirming. I’ll leave it open.
If we want to fix this, we need to change how the types are named which would affect everyone with breaking changes.
Before delving into this deeper, could you explain why you want users to be able to add both inline objectives and references to objectives?