Importing historical order history in GraphQl

Hi guys

We are starting to look into supporting historical order history across sales channels (online store, external pos, retired old webshops etc). We have previously done this using the REST Api for ‘order create’ which was rich in functionality, however stability of that specific API was poor in our experience (Seems like Shopify had a rough time processing very old orders). We’re trying to make the switch to use the GraphQl API, like most of our other integrations, however it does not seem like there’s a way to set ‘createdAt’ which seems to determine “Complete date” somewhat in the /account for the end customer.

I created a quick demonstration to show our issue.

The following GraphQl payload is sent:

{
  "order": {
    "name": "HistoricalOrder1",
    "sourceIdentifier": "",
    "closedAt": "2025-03-30T08:14:11.5000000Z",
    "processedAt": "2025-03-28T08:14:11.5000000Z",
    "buyerAcceptsMarketing": true,
    "email": "tnb@novicell.dk",
    "currency": "DKK",
    "financialStatus": "PAID",
    "fulfillmentStatus": "FULFILLED",
    "poNumber": "123",
    "phone": "+4520304050",
    "taxesIncluded": true,
    "fulfillment": {
      "locationId": "gid://shopify/Location/85771288885",
      "notifyCustomer": false,
      "trackingNumber": "123",
      "shipmentStatus": "DELIVERED"
    },
    "lineItems": [
      {
        "title": "An item",
        "sku": "p1v1",
        "variantId": "gid://shopify/ProductVariant/46259409781045",
        "quantity": 1,
        "requiresShipping": false,
        "variantTitle": "My variant",
        "priceSet": {
          "shopMoney": {
            "amount": "100",
            "currencyCode": "DKK"
          }
        }
      }
    ],
    "transactions": [
      {
        "status": "SUCCESS",
        "amountSet": {
          "shopMoney": {
            "amount": 100,
            "currencyCode": "DKK"
          }
        },
        "authorizationCode": "test-123",
        "gateway": "My test gateway",
        "kind": "SALE",
        "processedAt": "2025-03-29T08:14:11.5000000Z",
        "test": true
      }
    ]
  },
  "options": {
    "inventoryBehaviour": "BYPASS",
    "sendReceipt": false,
    "sendFulfillmentReceipt": false
  }
}

Here we would expect the order to be createdAt ‘2025-03-28T08:14:11.5000000Z’ and completed / closed ’

2025-03-30T08:14:11.5000000Z’

Shopify responds with the following dates:

            "order": {
                "id": "gid://shopify/Order/6556306833717",
                "createdAt": "2025-05-01T11:50:09Z",
                "processedAt": "2025-03-28T08:14:11Z",
                "closedAt": "2025-03-30T08:14:11Z"
            },

The order shows up in the /account page the following way:

Our main issue here is that it is sorted by Complete date, where this seems to correspond with the Shopify generated ‘createdAt’ date. However, our clients are expected to import orders going waaaay back, meaning several years and it would be misleading to the end customer if all their old purchases shows at the top of the account page.

Anyone found any workarounds using existing GrahpQl API’s?

Thanks!

1 Like

Hey @Berthelmaster :waving_hand: - when it comes to the sorting/display order for orders in a shop’s admin UI, it should automatically sort them based on the processed_at date, but by default in API responses we do sort them by created_at and it’s not possible to change that when creating the order via the GraphQL admin API.

If you’re referring to how these orders pop up on a customer’s account page on the shop’s frontend though, we do default to using the created_at date to sort an order, so that is likely why it’s showing up that way when customer’s check their orders themselves.

If you’re using a Liquid theme, you should be able to modify this on the account page to show the correct order (for our Dawn theme, this is located in sections>main-account.liquid). There are a few different ways to do this (the most common is filtering for orders by specific tags when they’re imported), but there’s a decent guide here to get started: Liquid reference

Hope this helps - let me know if I can clarify anything here.

@Alan_G That doesn’t address the problem.

Orders created through the API show up as new orders in the account page even though processed day can be years in the past.

The API need to allow setting of created_at field, so that offline orders are sorted correctly

Hey @Evaldas_Raisutis - thanks for reaching out here too. At the moment, setting created_at during the orderCreate mutation isn’t supported and is a current limitation, just wanted to confirm that.

I do know it’s a frequently asked for feature though. I can’t say for sure if/when it would be implemented, but I will pass this thread/your feedback on to the team so that we can get this looked at more thoroughly. Let me know if I can share any additional use cases for this as well with the team so we can advocate for the feature to be added, happy to help that way at the very least.