AutomationFlowsE-commerce › Paginate Shopify Products with Graphql Cursor-based Navigation

Paginate Shopify Products with Graphql Cursor-based Navigation

ByRichard Uren @elricho on n8n.io

Many Shopify GraphQL queries have the ability to return a cursor which you can loop over, however the N8N GraphQL node does not natively have the ability to fetch pages.

Event trigger★★☆☆☆ complexity5 nodesGraphQL
E-commerce Trigger: Event Nodes: 5 Complexity: ★★☆☆☆ Added:

This workflow corresponds to n8n.io template #5663 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "1VFYPRbT3Rm0LI8B",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Shopify Products by Cursor",
  "tags": [],
  "nodes": [
    {
      "id": "6afbcef7-96c0-46de-915f-e186c74c6d65",
      "name": "Start Workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        0,
        -120
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f845ead7-cf3d-4ab8-94ba-075763600875",
      "name": "Shopify, products",
      "type": "n8n-nodes-base.graphql",
      "position": [
        220,
        -120
      ],
      "parameters": {
        "query": "query ($pageSize: Int!, $cursor: String) {\n    products(first: $pageSize, after: $cursor) {\n        edges {\n            node {\n                id\n                title\n                handle\n                createdAt\n                updatedAt\n            }\n        }\n        pageInfo {\n            hasNextPage\n            endCursor\n        }\n    }\n}",
        "endpoint": "https://store99563.myshopify.com/admin/api/2025-04/graphql.json",
        "variables": "={\n    \"pageSize\": 5,\n    \"cursor\": {{ $if($json?.data?.products?.pageInfo?.hasNextPage !== undefined, \"\\\"\" + $json.data.products.pageInfo.endCursor + \"\\\"\", \"null\"); }}\n}",
        "authentication": "headerAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "67c4c2ff-e653-438c-8200-909ee0ad1dd4",
      "name": "hasMoreProducts",
      "type": "n8n-nodes-base.if",
      "position": [
        440,
        -120
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "a31f61a1-242c-418b-8e5a-ad878a439246",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $json.data.products.pageInfo.hasNextPage }}",
              "rightValue": "true"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "d3fef035-b854-49ac-ba22-7ed66444dda3",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        -360
      ],
      "parameters": {
        "width": 780,
        "height": 220,
        "content": "## Shopify GraphQL cursor loop\n\nMany Shopify GraphQL queries have the ability to return a cursor which you can loop over, however the N8N GraphQL node does not natively have the ability to fetch pages.  This simple 3 node workflow displays how to setup a cursor to fetch all items in a collection. \n\nNote : The pageSize in the \"Shopify, products\" node is set to 5 to illustrate how querying by cursor works. In production you would set this to a much larger value. Also, Update the Endpoint in GraphQL node to reflect your Shopify store."
      },
      "typeVersion": 1
    },
    {
      "id": "6bcd2224-c82b-4b3e-a0e0-773a4fffc166",
      "name": "Wait 1s",
      "type": "n8n-nodes-base.wait",
      "position": [
        660,
        0
      ],
      "parameters": {
        "amount": 1
      },
      "typeVersion": 1.1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "5734f646-93c7-41bf-ba1f-3ebc95cacf9b",
  "connections": {
    "Wait 1s": {
      "main": [
        [
          {
            "node": "Shopify, products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start Workflow": {
      "main": [
        [
          {
            "node": "Shopify, products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "hasMoreProducts": {
      "main": [
        [
          {
            "node": "Wait 1s",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Shopify, products": {
      "main": [
        [
          {
            "node": "hasMoreProducts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Many Shopify GraphQL queries have the ability to return a cursor which you can loop over, however the N8N GraphQL node does not natively have the ability to fetch pages.

Source: https://n8n.io/workflows/5663/ — original creator credit. Request a take-down →

More E-commerce workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

E-commerce

This workflow runs daily to find open, unpaid Shopify orders, send staged payment reminder emails via Gmail, and automatically cancel long-unpaid orders while restocking inventory. It also emails an a

Error Trigger, Gmail, GraphQL
E-commerce

Shopify + Mautic. Uses shopifyTrigger, noOp, mautic, crypto. Event-driven trigger; 26 nodes.

Shopify Trigger, Mautic, Crypto +1
E-commerce

Having a seamless flow of customer data between your online store and your marketing platform is essential.

Shopify Trigger, Mautic, Crypto +1
E-commerce

Shopify + Mautic. Uses shopifyTrigger, mautic, crypto, graphql. Event-driven trigger; 26 nodes.

Shopify Trigger, Mautic, Crypto +1
E-commerce

Shopify + Mautic. Uses shopifyTrigger, mautic, crypto, graphql. Event-driven trigger; 26 nodes.

Shopify Trigger, Mautic, Crypto +1