question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to deploy schema field with ref and object array

See original GitHub issue

When 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

Screen Shot 2021-08-02 at 10 53 15 PM

Sanity version: 2.7.4

Node version: 16

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
geballcommented, Jan 7, 2022

Okay, thanks for confirming. I’ll leave it open.

1reaction
saasencommented, Sep 20, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found