news-catalyst / reproducible-tinynews-content-api

A webiny installation complete with scripted content models and graphql
0 stars 0 forks source link

Feature/publish and unpublish article mutations #62

Closed jacqui closed 3 years ago

jacqui commented 3 years ago

Related to https://github.com/news-catalyst/google-app-scripts/issues/153

Issue #61

This adds 2 new mutations to articles in the API: publishArticle sets article.published to true while updating the publishedOn date(s) and unpublishArticle sets article.published to false.

To test:

  1. Use this deployed testing API: https://d3ahlfgcyw174q.cloudfront.net/graphql and token: 9178c7f1e6bac26195f2f6e1460450c2adcb24cc97b5085a

  2. List articles with the following query and note the value of published.

query ListArticles($where: ArticleListWhere) {
  articles {
    listArticles(where: $where) {
      data {
        id
        parent
        version
        latestVersion
        published
        slug
        headline {
          values {
            value
            locale
          }
        }
      }
    }
  }
}
{
  "where": {
     "slug": "test-pub-dates-pub-true-2" 
  }
}
  1. Publish and unpublish the article (depending on its value when you first view it):
mutation PublishArticle($revision: ID!) {
  articles {
    publishArticle(revision: $revision) {
      error {
        code
        message
        data
      }
      data {
        id
        slug
        parent
        version
        latestVersion
        published
        firstPublishedOn
        lastPublishedOn
      }
    }
  }
}
mutation UnpublishArticle($revision: ID!) {
  articles {
    unpublishArticle(revision: $revision) {
      error {
        code
        message
        data
      }
      data {
        id
        slug
        parent
        version
        latestVersion
        published
        firstPublishedOn
        lastPublishedOn
      }
    }
  }
}
{
  "revision": "5ff5155d2be98800082c321c"
}