Creating checkout with items returning null with graphql storefront API

Solved
cmatus
New Member
2 1 1

When using the graphql storefront api, I can create an empty checkout, but if I try to create a checkout with items, or add items to an existing checkout, the checkout comes back null.

This works:

mutation {
  checkoutCreate(input: {}) {
    checkout {
      id
      webUrl
      lineItems(first: 5) {
        edges {
          node {
            title
            quantity
          }
        }
      }
    }
  }
}

which returns

{
  "data": {
    "checkoutCreate": {
      "checkout": {
        "id": "Z2lkOi8vc2hvcGlmeS9DaGVja291dC80NGFkMzA1NzEyNmVjMTY0YzU0ODE0MGQ1OWU1ZjcyYj9rZXk9ZDNlNjRkNzU2ODg2NDdiNzJmNDViNzcwYjYyYWQ3MTM=",
        "webUrl": "https://knowyourh2o.myshopify.com/25164513346/checkouts/44ad3057126ec164c548140d59e5f72b?key=d3e64d75688647b72f45b770b62ad713",
        "lineItems": {
          "edges": []
        }
      }
    }
  }
}

But this fails:

mutation {
  checkoutCreate(input: {
    lineItems: [{ variantId: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMjE0ODUzODYyMjAxOA==", quantity: 1 }]
  }) {
    checkout {
       id
       webUrl
       lineItems(first: 5) {
         edges {
           node {
             title
             quantity
           }
         }
       }
    }
  }
}

which returns:

{
  "data": {
    "checkoutCreate": {
      "checkout": null
    }
  }
}

I can't for the life of me figure out what he issue is.  The variantID is correct as verified by the below  query to the admin by using the variantID:

query {
  node(id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMjE0ODUzODYyMjAxOA==") {
    ... on ProductVariant {
id
    }
  }
}

which returns:

{
  "data": {
    "node": {
      "id": "gid://shopify/ProductVariant/32148538622018"
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 1,
      "actualQueryCost": 1,
      "throttleStatus": {
        "maximumAvailable": 1000,
        "currentlyAvailable": 999,
        "restoreRate": 50
      }
    }
  }
}

Can anyone point me in the right direction?

Thank you!

Accepted Solution (1)
cmatus
New Member
2 1 1

This is an accepted solution.

Figured it out.  Total newbie problem.  The product was not yet made available to the sales channel.

View solution in original post

Replies 3 (3)
cmatus
New Member
2 1 1

This is an accepted solution.

Figured it out.  Total newbie problem.  The product was not yet made available to the sales channel.

cjdev
New Member
2 0 0

Hi,

I'm experiencing the same issue. I thought all the products were in the sales channel. Is there a way to check which products could be missing?

comfycccr
New Member
1 0 0

DUDE!!!!!!!!!!!!!!!! After 10 hours, you saved my but.!!!!!! Also to any new people, make sure your on the latest api version. The docs dont reflect it.