Bug: assignedFulfillmentOrders graphql call returning empty array for cancellation requests

precisionlaser
Shopify Partner
15 1 0

My app is setup to receive the FULFILLMENT_REQUEST and CANCELLATION_REQUEST requests via a callback endpoint on my server. The fulfillment request side works flawlessly and reliably, but I can't get the cancellation request side to work at all. As an example for this post, I created a test order in my dev store and it arrived at the endpoint complete with all of the fulfillment order information. I accepted the order and then submitted a cancellation request. At the callback, I got a response but only an empty edges array where the product info should have been found. My graphql query is as follows:

{
  shop {
    assignedFulfillmentOrders(first: 10, assignmentStatus: CANCELLATION_REQUESTED) {
      pageInfo {
        hasNextPage
        hasPreviousPage
      }
      edges {
        cursor
        node {
          id
          requestStatus
          merchantRequests(first: 10, reverse: true) {
            edges {
              cursor
              node {
                message
                sentAt
              }
            }
          }
        }
      }
    }
  }
}

This is what I get back:

{
  "errors": false,
  "response": {},
  "status": 200,
  "body": {
    "data": {
      "shop": {
        "assignedFulfillmentOrders": {
          "pageInfo": {
            "hasNextPage": false,
            "hasPreviousPage": false
          },
          "edges": []
        }
      }
    },
    "extensions": {
      "cost": {
        "requestedQueryCost": 133,
        "actualQueryCost": 3,
        "throttleStatus": {
          "maximumAvailable": 1000,
          "currentlyAvailable": 997,
          "restoreRate": 50
        }
      }
    }
  },
  "timestamps": [
    1602981962.5611119
  ]
}

Is this a bug in the api or am I doing something wrong??  Help please

Replies 13 (13)
_JB
Shopify Staff
Shopify Staff
836 99 211

Hey @precisionlaser,

Can you share a few example order ids? I'll use this to check the logs and hopefully find more information about why you're seeing an empty response.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

precisionlaser
Shopify Partner
15 1 0

Here's an order I just created: 

gid://shopify/FulfillmentOrder/2816594968739

 

As usual, I received the FULFILLMENT_REQUEST callback. I queried for the id(s) and got the order detail back as normal. I never have a problem with this. I then "accepted" the order and verified that it was acknowledged on my test store. I then requested cancellation on my store. The callback was received as usual, and I queried to get the relevant ids as follows:

{
	shop {
		assignedFulfillmentOrders(first: 250, assignmentStatus: CANCELLATION_REQUESTED, locationIds: ["gid://shopify/Location/58250494115"]) {
			edges {
				node {
					id
				}
			}
		}
	}
}

 

I then received the following response which had the empty edges array:

{
    "errors": false,
    "response": {},
    "status": 200,
    "body": {
        "data": {
            "shop": {
                "assignedFulfillmentOrders": {
                    "edges": []
                }
            }
        },
        "extensions": {
            "cost": {
                "requestedQueryCost": 253,
                "actualQueryCost": 3,
                "throttleStatus": {
                    "maximumAvailable": 1000,
                    "currentlyAvailable": 997,
                    "restoreRate": 50
                }
            }
        }
    },
    "timestamps": [
        1608058302.736351
    ]
}

 

I'm guessing I've somehow screwed up but I can't figure out how!

precisionlaser
Shopify Partner
15 1 0
Sure, I just created this order:
gid://shopify/FulfillmentOrder/2816594968739



As usual, I received the FULFILLMENT_REQUEST callback. I queried for the
id(s) and got the order detail back as normal. I never have a problem with
this. I then "accepted" the order and verified that it was acknowledged on
my test store. I then requested cancellation on my store. The callback was
received as usual, and I queried to get the relevant ids as follows:



{
shop {
assignedFulfillmentOrders(first: 250, assignmentStatus:
CANCELLATION_REQUESTED, locationIds: ["gid://shopify/Location/58250494115"])
{
edges {
node {
id
}
}
}
}
}



I then received the following response which had the empty edges array:



{
"errors": false,
"response": {},
"status": 200,
"body": {
"data": {
"shop": {
"assignedFulfillmentOrders": {
"edges": []
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 253,
"actualQueryCost": 3,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 997,
"restoreRate": 50
}
}
}
},
"timestamps": [
1608058302.736351
]
}


precisionlaser
Shopify Partner
15 1 0

Hey @_JB,

I never got any feedback. I'm almost ready for review but there's this one gaping hole. Help please!

_JB
Shopify Staff
Shopify Staff
836 99 211

Hey @precisionlaser,

Do you mind if I preform create some orders+fulfillments on your store? I'm still not sure why the response is empty so I'd like to test myself to see what's happening.

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

precisionlaser
Shopify Partner
15 1 0
Hi JB

No problem at all. Thank you for your help! What do you need from me to do
this? I have the app setup on my test store Laser Creations and More and I
have a product called Arkansas Cube that is set up for order. If you would
like to speak with me on anything my phone number is 901-481-3285 (US)
precisionlaser
Shopify Partner
15 1 0

@_JB, no problem at all. I sent a private reply with some info.

precisionlaser
Shopify Partner
15 1 0

@_JB 

I just submitted a test order, accepted it and then requested cancellation. Same thing with empty edges

_JB
Shopify Staff
Shopify Staff
836 99 211

Hey @precisionlaser,

I copy/pasted your query, but I got an error instead of empty edges. I dug into the logs and it seems the query wasn't working because it was passing a location which wasn't managed by your app. The id used in your query was for the default location created for the shop, but your fulfillment service uses a different location.

I changed the location id in the query to 59084505251 and got back a response containing a FulfillmentOrder:

{
    "shop": {
      "assignedFulfillmentOrders": {
        "edges": [
          {
            "node": {
              "id": "gid://shopify/FulfillmentOrder/2881698234531"
            }
          }
        ]
      }
    }
  }

 

JB | Solutions Engineer @ Shopify 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

precisionlaser
Shopify Partner
15 1 0
I knew it had to be something I did. That location id works for the
fulfillment request though, but not for the cancellation request. Wouldn't
they want to use the same id? I'll change the code, though. Thanks!


precisionlaser
Shopify Partner
15 1 0

@_JB

Ugh, I am using the id you referenced and while the fulfillment request side works and has always worked, the cancellation side does not. The only difference in the query is substituting CANCELLATION_REQUESTED for FULFILLMENT_REQUESTED. I sent a log of the graphql queries and responses to you via email reply. Why would one side work and the other not work if that is the only difference between the queries?

davisg2
Tourist
5 0 3

+1 I also have this issue, immediately after the endpoint is called with 

CANCELLATION_REQUEST

the query for assigned fulfillment orders with assignment_status

cancellation_requested

 is always empty. I tried inserting a 5 second delay but still nothing

precisionlaser
Shopify Partner
15 1 0

In my case, I was trying to process the request in the callback request handler. For some reason, that worked flawlessly in the case of the fulfillment request but never worked for the cancellation request. What did the trick for me was simply spawning off asynchronous jobs to handle the requests. That was a better design anyway, but I don't know why that fixed the issue.