Hi,
Today The draftOrderCreate method started failing suddenly on a store I manage. The endpoint that is calling the mutation on my hand hasn't been modified for months and neither has the website.
Below I'll show you the mutation, input and output I'm receiving.
Mutation:
mutation($input: DraftOrderInput!, $lineItemsFirst: Int, $metafieldsFirst: Int) {
draftOrderCreate(input: $input) {
draftOrder {
...draftOrder
lineItems(first: $lineItemsFirst) {
edges {
node {
...lineItem
discountedTotal
appliedDiscount {
title
amountV2 {
amount
currencyCode
}
value
valueType
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
}
}
}
}
}
Here's the input/output:
input:
{
'lineItemsFirst': 50,
'metafieldsFirst': 8,
'input': {
'lineItems': [{
'variantId': 'gid://shopify/ProductVariant/26139281883200',
'quantity': 1,
'sku': '61514'
}]
}
}
output:
{
'draftOrderCreate': {
'draftOrder': None
}
}
Any ideas on what might be wrong? I've been looking into this for a few hours but I have no idea why it's happening
You declare the metafieldsFirst variable, but don't use it later on. When I tried this in my GraphiQL app that's what kicked back as an error. When I tried the GQL request below it worked fine.
mutation ($input: DraftOrderInput!, $lineItemsFirst: Int) {
draftOrderCreate(input: $input) {
draftOrder {
lineItems(first: $lineItemsFirst) {
edges {
node {
discountedTotal
appliedDiscount {
title
amountV2 {
amount
currencyCode
}
value
valueType
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
}
}
}
}
}
with the query variables
{
"lineItemsFirst": 50,
"input": {
"lineItems": [{
"variantId": "gid://shopify/ProductVariant/31620852416564",
"quantity": 1,
"sku": "61514"
}]
}
}
we're receiving the same error! suddenly out of nowhere all our orders started failing since draft orders were not getting create on Shopify.
our input parameters are:
{shippingAddress:{zip:"POSTCODE",phone:"+4412345678",lastName:"X",firstName:"X",country:"GB",city:"London",address2:null,address1:"X"},lineItems:[{variantId:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMTc4MjM5MTc3NTI2Nw==",quantity:1,appliedDiscount:{valueType:FIXED_AMOUNT,value:2.26,title:"Discount",amount:"2.26"}},{variantId:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMTYxNDg1MjMwMDgzNQ==",quantity:1,appliedDiscount:{valueType:FIXED_AMOUNT,value:2.700000000000001,title:"Discount",amount:"2.700000000000001"}},{variantId:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMjA0NTUzNTIzMjAzNQ==",quantity:1,appliedDiscount:{valueType:FIXED_AMOUNT,value:2.0,title:"Discount",amount:"2.0"}},{variantId:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMTYxNDg0OTQ1MDAxOQ==",quantity:1,appliedDiscount:{valueType:FIXED_AMOUNT,value:2.5,title:"Discount",amount:"2.5"}}],billingAddress:{zip:"POSTCODE",phone:"+4412345678",lastName:"X",firstName:"X",country:"GB",city:"London",address2:null,address1:"X"},email:"email@provider.com"}
the graphql requst is:
draftOrderCreate(input: #{input}) {
userErrors {
field
message
}
draftOrder {
id
totalPrice
totalShippingPrice
totalTax
subtotalPrice
lineItems(first: 250) {
edges {
node {
id
quantity
variant {
id
}
}
}
}
}
}
And the response is:
"data" => %{
"draftOrderCreate" => %{
"draftOrder" => nil,
"userErrors" => [
%{"field" => nil, "message" => "Invalid input arguments."}
]
}
},
"extensions" => %{
"cost" => %{
"actualQueryCost" => 10,
"requestedQueryCost" => 10,
"throttleStatus" => %{
"currentlyAvailable" => 990,
"maximumAvailable" => 1.0e3,
"restoreRate" => 50.0
}
}
}
},
it suddenly happened today around 4/5PM GMT+1 (London time). we haven't changed/touched this since 2019.
What is going on? We have a live app and it's crucial for us to get this fixed. We spoke to the support but they haven't come back to us with a solution just yet
what do you mean don't use it later on?
The full mutation is as follows, (I left the fragments out in my former post)
mutation($input: DraftOrderInput!, $lineItemsFirst: Int, $metafieldsFirst: Int) {
draftOrderCreate(input: $input) {
draftOrder {
...draftOrder
lineItems(first: $lineItemsFirst) {
edges {
node {
...lineItem
discountedTotal
appliedDiscount {
title
amountV2 {
amount
currencyCode
}
value
valueType
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
}
}
}
}
} fragment draftOrder on DraftOrder {
id
totalPrice
totalTax
subtotalPrice
status
} fragment lineItem on DraftOrderLineItem {
id
title
quantity
customAttributes {
key
value
}
product {
id
title
handle
descriptionHtml
description
}
variant {
...variant
}
} fragment variant on ProductVariant {
id
title
price
sku
compareAtPrice
createdAt
requiresShipping
updatedAt
weight
weightUnit
selectedOptions {
name
value
}
image {
id
originalSrc
transformedSrc
altText
}
metafields(first: $metafieldsFirst) {
edges {
node {
key
value
}
}
}
}
The query I'm using has been working for a long while now and as another comment below stated it stopped working for them at the same time.
This shouldn't be a code issue since it has worked for a while now
Yes, it does sound like a more global issue seeing that multiple API consumers ran into the issue right around the same time. With untouched code that hasn't been modified. Sorry @arnarfs , I didn't originally see your fragments, so I didn't see where the metafieldsFirst variable was coming into play. Now it makes sense! Seeing this appears to be a back-end Shopify GQL handling issue I'm surprised no Shopify staffer has replied as to the current status.
It seems I am experiencing the same problem when dealing with any mutation using GraphQL. Here the example of the code:
`mutation productCreate {
productCreate(input: {title: "title"}) {
product {
id
}
}
}
`
example of the response:
`{
"errors": [
{
"message": "Field 'productCreate' doesn't exist on type 'Mutation'",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"mutation productCreate",
"productCreate"
],
"extensions": {
"code": "undefinedField",
"typeName": "Mutation",
"fieldName": "productCreate"
}
}
]
}`
It seems like there is some issue with the Shopify API and it doesn`t allow me to do any mutation.
@Flick-Flack Strange. Is there a specific API version your are referencing in your URL? When I just tried this using the GraphiQL app on my test shop the call worked fine. See below.
When I use the built-in GraphiQL app from the test shop everything is working fine. The issue happens when I am trying to do it using my own application with the help of the GraphiQL.
So I have been doing research whether it is possible to create an order in the Shopify with the help of the GraphiQL app. I was able to send requests and get the data.
I don`t why but for some reason, it won`t work when I do it from other application sending the same request in both cases.
User | Count |
---|---|
13 | |
12 | |
7 | |
4 | |
4 |