GraphQL draftOrderComplete generates random results in orders & send order confirmation duplicately

GraphQL draftOrderComplete generates random results in orders & send order confirmation duplicately

mktb
Shopify Partner
3 0 1

Hello,

please let me share a strange phenomenon while processing draft orders with draftOrderComplete mutation here and I need your help to solve this. Attachment is a figure explaining this problem.

I'm using API version 2022-10

 

[Problem]

  • Order confirmation mail sent to customer twice despite that draftOrderComplete was invoked just once.
  • Strangely, there are 2 variants of order after draftOrderComplete (successful and error).
  • Successful order has subtitle of "APP NAME (via import)" and sending order confirmation email just once.
  • Error order has subtitle of just APP NAME and sending duplicated order confirmation emails as mentioned above.

[Flow of my current code]

  1. Invoke draftOrderCreate mutation
  2. Catch DRAFT_ORDERS_CREATE topic in a webhook and wait for the draft order's "Ready" status with polling loop
  3. Once the draft order is ready, invoke draftOrderComplete mutation
  4. Forward a result of draftOrderComplete mutation to my email address as debug information (that's why I confirmed draftOrderComplete was surely called just once even though it send order confirmation email twice)

The reason why I use webhook catching DRAFT_ORDERS_CREATE instead of calling draftOrderComplete just after draftOrderCreate is, to guarantee my code calls draftOrderComplete just once. (but it seems using webhook doesn't solve the trouble)

Replies 4 (4)

mktb
Shopify Partner
3 0 1
Let me share one result of draftOrderComplete which generating "error" order (sending duplicated order confirmation email as shown in the previously attached .pptx file).
I don't see any errors at userErrors property though..

 

{
  "draftOrderComplete": {
    "draftOrder": {
      "id": "gid://shopify/DraftOrder/923981775032",
      "name": "#D533",
      "order": {
        "id": "gid://shopify/Order/4884808106168",
        "name": "#1526",
        "__typename": "Order"
      },
      "__typename": "DraftOrder"
    },
    "userErrors": [],
    "__typename": "DraftOrderCompletePayload"
  }
}

 

ShopifyDevSup
Shopify Staff
1453 238 508

Hey @mktb, could you share a plain text X-Request-ID that would have been sent in the responses headers you received back from us for the draft order that errored? 

We can use that to take a look into the exact API call in our logs and see if we can potentially track down what's causing the draft order creation process to duplicate. 

Thanks - hope to hear from you soon! 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

mktb
Shopify Partner
3 0 1

Hello @ShopifyDevSup ,

Thank you for your reply!
Please let me share the X-Request-IDs of two errored orders and one successful order here.

I'm logging IDs of both draftOrderCreate & draftOrderComplete mutations for your reference.

 

[Errored order 1]
draftOrderCreate
Creating: gid://shopify/DraftOrder/924191916216
X-Request-ID: 8b9d20b3-0ad9-495d-a58e-d21510963324

draftOrderComplete
Converting from: gid://shopify/DraftOrder/924191916216
To: gid://shopify/Order/4888265752760
X-Request-ID: 06968e17-4fb4-4719-a301-818daabe64e6


[Errored order 2]
draftOrderCreate
Creating: gid://shopify/DraftOrder/924195586232
X-Request-ID: 292b2a22-518b-41b1-bb80-5801784af3fd

draftOrderComplete
Converting from: gid://shopify/DraftOrder/924195586232
To: gid://shopify/Order/4888377721016
X-Request-ID: 6b7ab838-8c52-4f99-8726-f9d1e8bb652e


[Successful order (for reference)]
draftOrderCreate
Creating: gid://shopify/DraftOrder/924197519544
X-Request-ID: ffb2a532-ed2a-4dda-887d-95590ecefe49

draftOrderComplete
Converting from: gid://shopify/DraftOrder/924197519544
To: gid://shopify/Order/4888388993208
X-Request-ID: 411071c4-324e-442f-9bcf-b14004915bcf

 

ShopifyDevSup
Shopify Staff
1453 238 508

Thank for sending that info over @mktb - really appreciated! I wanted to get back in touch to confirm that our developers are currently looking into this. I can't guarantee a turnaround time or an exact resolution at the moment, but did want to update you on this. I'll reach back out once I have more information - just wanted to confirm that it does appear that similar issues relating to draft orders/email confirmations have been reported by others. 

 

Thanks for bringing this to us - please keep an eye out for a response from me or one of my colleagues. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog