Retreiving Blocks from a Workdoc stored in a board's monday Doc column?

Hi there.

I want to build an app for monday.com, and would like to read the contents of Workdocs.

I know I can get all docs via:

query {
  docs {
    id
		name
  }
}

Then, get the blocks for a specific doc via:

{
  docs(ids: "1528931161") {
    blocks {
      type
      content
      id
    }
  }
}

That works for “regular” Workdocs. It doesn’t work for Workdocs that are stored inside a board’s monday Doc column:

There is some documentation about reading the mondy Doc column, but I’m struggling to understand how to read the docs’s blocks?

Also, I’m wondering why does the api not return the workdocs that are stored inside boards, when I query for ALL workdocs. (the first query posted)

Hello there @wnm,

You can use a query like this one to get the “object ID” of the doc:

{
  items(ids: 1234567890) {
    column_values(ids: "monday_doc__1") {
      value
    }
  }
}

Then you can use that ID in a new query to get the content of the doc:

{
  docs(object_ids: [1112223334]) {
    blocks {
      content
      type
    }
  }
}

As of today, the general “docs” query will only get docs from the left pane.

Let me know if you have any other questions :smile:

Cheers,
Matias

Hi @Matias.Monday,

thanks so much for your reply! that makes total sense… quite obvious in hindsight :sweat_smile:

I actually do have another question. I’ve been playing around with the api quite a bit, and one thing I tried to do was to find out how the different blocks where returned by the api. And I stumbled upon something weird, when using a “notice box” block.

In monday, it looks like this:

But the api, returns the blocks in a strange order:

{
  "data": {
    "docs": [
      {
        "blocks": [
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[]}",
            "id": "92a7db06-2826-4bd7-9dde-6a7f779b9ae3"
          },
          {
            "type": "notice box",
            "content": "{\"theme\":\"tips\",\"alignment\":\"left\",\"direction\":\"ltr\"}",
            "id": "87e4dd41-6640-4050-bd62-e0ea2aabeb5d"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[]}",
            "id": "5aa5baba-e51d-4998-82cb-3887d8df3091"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"Ah wrong order\"}]}",
            "id": "d6521d56-3192-4f76-9874-5c730eab2034"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[]}",
            "id": "8725f941-f1eb-4fb7-bec4-78659eedb16a"
          },
          {
            "type": "notice box",
            "content": "{\"theme\":\"info\",\"alignment\":\"left\",\"direction\":\"ltr\"}",
            "id": "78434a45-21e7-4fab-96a8-2387386b6edb"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[]}",
            "id": "08537fc9-4550-4f42-9684-8277b9b2deed"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"mh, that is strange\"}]}",
            "id": "1c485b60-aced-4c50-846a-2dcd7ba51fb9"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[]}",
            "id": "9a82a053-c4f4-47dc-a022-dc56204bd806"
          },
          {
            "type": "normal text",
            "content": "{\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"Yes, this might be a good idea!\"}]}",
            "id": "5b490486-28b2-4f1e-b4a5-0d049ddf166f"
          },
          {
            "type": "normal text",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"Attention!\"}]}",
            "id": "a385cfa1-4393-4c2a-8b23-84e57bcd3332"
          }
        ]
      }
    ]
  },
  "account_id": ...
}

I noticed that when I use a “code” block, or a “quote” block, the api returns the content within the block, in an insert attribute… but the notice box block returns the text part of the block in a different block, completely out of order:

{
  "data": {
    "docs": [
      {
        "blocks": [
          {
            "type": "notice box",
            "content": "{\"theme\":\"info\",\"alignment\":\"left\",\"direction\":\"ltr\"}",
            "id": "cd89d37c-0b7a-41ad-a15a-9745b3d28600"
          },
          {
            "type": "quote",
            "content": "{\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"quote of the thing\"}]}",
            "id": "2e011825-448d-409d-927e-e8e19741c905"
          },
          {
            "type": "code",
            "content": "{\"language\":\"ruby\",\"alignment\":\"left\",\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"# code block \\n\\ndef method\\nend\"},{\"insert\":\"\\n\",\"attributes\":{\"code-block\":true}}]}",
            "id": "7225cd17-88c5-4d3b-a39f-c0361f298970"
          },
          {
            "type": "normal text",
            "content": "{\"direction\":\"ltr\",\"deltaFormat\":[{\"insert\":\"test notice\"}]}",
            "id": "4d2b3dd3-1485-47e6-92b2-e6c8e537ef52"
          }
        ]
      }
    ]
  },
  "account_id": ...
}

Is that a bug potentially?

Hello again @wnm,

Would you be able to please fill this form adding as much information as possible to it so that our team can take a look into it?

Hi Matias,

in this query
{
docs(object_ids: [1112223334]) {
blocks {
content
type
}
}
},

shouldn’t we be able to use more than one object ids? For example ’ docs(object_ids: [1112223334, 12345678])'? Such a query does not seem to return the desired result. Am I doing something wrong here? I want to fetcch two docs at once here.

Hello there @manishaghosh!

Would you be able to please fill this form adding as much information as possible to it so that our team can take a look into it?