Search code examples
strapi

How do I save as draft in strapi?


currently i've manage to post into strapi, but i cant set post status to draft. I am using graphql, and there is no post status in mutation. what I have to do?

thanks.


Solution

  • The way that I found to do that is just passing the property published_at as null when perform the mutation.

    published_at is a default property that strapi assign to each collection.

    For the query

    mutation CreateRecord (
      $recordName: String!,
      $published_at: DateTime
    ) {
      createComment (input: {
        data : {
          recordName: $recordName,
          published_at: $published_at
        }
      })
    }
    

    and when is time to send the values

    createRecords({
      variables: {
        recordName: "I am a new record saved as draft"
        published_at: null
      }
    });