0

I need to insert alot of data into sanity and I will do this with a node script. My issue is that the documents does not seem to publish once I insert them.

I use client.create(data) and the data is inserted, but I need to make changes to the document and then publish for it to actually be published. Is there a way around this?

Moddah
  • 51
  • 1
  • 7
  • the document logs says it was first created and then edited. But not published, but I need to unpublish before I can publish it, this seems rather redundant if I need to manually publish every document. – Moddah Jun 24 '21 at 16:05

1 Answers1

1

This shouldn't be the case... What exactly do you mean by a document being published?

As long as you can query it through Sanity's API (or @sanity/client, or the vision studio plugin), and the document doesn't have a drafts. in their _id (in which case they're drafts), the document is already published.

If you added dots/periods to the _id of your created documents in client.create() (ex: migrated.post.random-string), this could be the culprit. These portions separated by periods are _id paths, which by default are only accessible by authenticated users with read rights.

That means you won't be able to get this data in your front-end(s) unless you use a robot token, which is why drafted documents (_id = drafts.rest-of-id) don't show up there.

Does this clarify the issue in any way? Let me know how else I can help

Henrique Doro
  • 436
  • 4
  • 7