Not possible to set the status of a new product to "draft" using the productCreate graphql mutation

Solved
Pab89
Tourist
5 1 0

Hi

I have a working integration between my client´s POS & his Shopify shop.

Last week he asked me to let new products being create set as "draft" instead of "active".

No problem I thought, but this seems impossible.

I am using the latest GraphQL API and I keep getting the following error "status": "DRAFT", "Field is not defined on ProductInput"

 

I have tried copying the GraphQL example from "https://shopify.dev/tutorials/use-statuses-to-identify-filter-and-manage-products?itcat=partner_blog... at "Create a new draft product" directly into the GraphiQL App of my shop.

 

The example I copied into GraphiQL

mutation {
  productCreate(input: {title: "Burton Custom Freestyle 151", productType: "Snowboard", vendor: "Burton", status: "DRAFT"}) {
    product {
      id
      status
    }
  }
}

 The response I got:

{
  "errors": [
    {
      "message": "InputObject 'ProductInput' doesn't accept argument 'status'",
      "locations": [
        {
          "line": 2,
          "column": 107
        }
      ],
      "path": [
        "mutation",
        "productCreate",
        "input",
        "status"
      ],
      "extensions": {
        "code": "argumentNotAccepted",
        "name": "ProductInput",
        "typeName": "InputObject",
        "argumentName": "status"
      }
    },
    {
      "message": "Field 'status' doesn't exist on type 'Product'",
      "locations": [
        {
          "line": 5,
          "column": 7
        }
      ],
      "path": [
        "mutation",
        "productCreate",
        "product",
        "status"
      ],
      "extensions": {
        "code": "undefinedField",
        "typeName": "Product",
        "fieldName": "status"
      }
    }
  ]
}

 Has anyone had any luck of creating new products with the productCreate mutation that are set as drafts=

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 246

I believe that ProductStatus is an enum. So in your GraphiQL test scenario just leave off the quotes. Rather than "DRAFT" just have DRAFT and it should work!

Untitled.png

Pab89
Tourist
5 1 0

This is an accepted solution.

Thanks a lot, I figured out the problem, but it was not the ENUM thing. I was using 2020-07 API, when i changed to 2021-01, it worked.

 

But your post put me on the right path when I saw it worked for you.

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 246

Glad you got it working. Apparently the newer API version supports this feature. Although if you stick quotes around the status using the 2021-01 API version, it still won't work.   

0 Likes