Receiving indication that content is partially published

Recently we stumbled upon a quite peculiar situation.

Example of the content model:
–plan (root)
----name: String
----title: String
----thingsToDo: Array

Now image that in the “thingsToDo” array the first element is draft and the second is published and we publish the root aswell.

Json representation:

"fields": {
  "name": "Top 10 things to do when sunny",
  "title": "It's :sunny:",
  "thingsToDo": [
    {
      "sys": {
        "type": "Link",
        "linkType": "Entry",
        "id": "4Zvy7o4HD2UeACMMEk6eGI"
      }
    },
    {
      "sys": {
        "space": {
          "sys": {
            "type": "Link",
            "linkType": "Space",
            "id": "k0ybvv7tq4yc"
          }
        },
        "id": "2tfUbXSeyoqA0eAeMgsooo",
        "type": "Entry",
        "createdAt": "2018-07-20T06:41:17.240Z",
        "updatedAt": "2018-07-20T06:41:17.240Z",
        "environment": {
          "sys": {
            "id": "master",
            "type": "Link",
            "linkType": "Environment"
          }
        },
        "revision": 1,
        "contentType": {
          "sys": {
            "type": "Link",
            "linkType": "ContentType",
            "id": "thingToDo"
          }
        },
        "locale": "ru-RU"
      },
      "fields": {
        "name": "Go biking",
        "targetLink": "http://www.best-biking-routes.com"
      }
    }
  ]
}

Now since content delivery API returns draft/archived content in such way that it partially includes draft content we need to start validating the model on service side.

What would be the recommended ways to handle this? Maybe you can provide a flag/header that would indicate whether this content is partially published?

Well for the UI part you’re already covered, no need to write any UI extension:

Just for the API publish we don’t validate it.

If you see an array item like this:

and not like the 2nd item in the array, it means the referenced entry is not published. That’s the easiest way to see if content is completely published or not.

I was hoping for an easiers solution as in UI side you already now this information.

In some cases our content models go 10 levels deep so we need to recursively traverse the whole object to get the confirmation.

I have the same issue but with a single reference and feel like there should be some way to query this instead of having to client-side validate if the reference is published or not.

In my example I have an “Article”-content type which you pick a “Article > Category”-entry for.
But I this query don’t work:
‘fields.category.fields[exists]=true’, because I guess the fields do “exist” server-side why that query don’t work.

And I weirdly cant write a rather hacky query like:
‘fields.category.sys.revision[gt]=1’, either because that gives me the error: “The path “fields.category.en-US.sys.revision” is not recognized”

I cant make the Category-field required for the article either because the client want to be able to pick “no category” as well.

Is there really no way to query this?

If you query for an Article that has a draft Category, then the api response will include an error object like this:

"errors": [
  {
    "sys": {
      "id": "notResolvable",
      "type": "error"
    },
    "details": {
      "type": "Link",
      "linkType": "Entry",
      "id": "13tMd7Kv0yW4m0Ogmio2k4"
    }
  }
]

where 13tMd7Kv0yW4m0Ogmio2k4 is the entry ID of the category.

As long as Category is a single reference, you can query for articles which have a published category (excluding articles with a draft category or no link category) like this:

curl -g -H "Authorization: Bearer $CDA_TOKEN"\ 
"https://cdn.contentful.com/spaces/qi0g1jkijtdx/entries?\
content_type=article&\
fields.category.sys.contentType.sys.id=category&\
fields.category.fields.name[exists]=true"

Assuming category has a name field

@gustaf.eriksson does that answer your question?