Adding a custom (GraphQL) endpoint for Shopify

Introduction

Shopify is phasing out its REST API capabilities and strongly recommends transitioning to GraphQL. If you've been using the Shopify connector with REST API endpoints, we advise updating the connector from the Patchworks marketplace, so GraphQL endpoints are available.

When browsing endpoints for the latest Shopify connector, you'll find that REST API endpoints are prefixed with the word LEGACY, and GraphQL endpoints are available:

A key advantage of GraphQL is that connector endpoints can be configured with queries that request only the data needed, minimising information over and under-fetching.

Our Shopify connector includes a range of predefined GraphQL endpoints with queries for different entity types (products, customers, orders, etc.). However, GraphQL is so flexible that you may want to add custom endpoints to the Shopify connector, with more targeted queries for your needs. This guide walks through the steps needed to achieve this.

Preparation

Ensure that your Patchworks Shopify connector is up to date. For more information please see Updating a connector.

The steps

Our suggested approach for adding custom GraphQL endpoints is to take a copy of an existing endpoint with similar properties and then edit the copy as needed. These steps are detailed in two stages:

Stage 1: Clone an existing endpoint

Step 1 Log in to the Patchworks dashboard and select process flows from the left-hand navigation menu:

Step 2 Select connectors & instances:

Step 3 Click the settings icon associated with your Shopify connector:

Step 4 You're now in the connector builder - click the endpoints option:

Step 5 Find an existing GraphQL query that's similar to the one you want to add. For example, if your new query relates to retrieving customer records, the GraphQL Retrieve a list of customers endpoint would be a good option:

Endpoints are organised by entity type - you can scroll through this list, or CTRL+F or CMD+F to search on the name.

Step 6 Scroll to the right and select the clone option:

Step 7 You'll see two confirmation messages - the first advising that the clone task is queued and the second confirming when the task is completed (these are typically instant but may take longer in busy times) - for example:

Step 8 Refresh the page (CTRL+ R or CMD+ R). Now you should see a copy of the endpoint with an incremented number in brackets - for example:

Stage 2: Edit your new endpoint

Step 1 Click the name of the newly cloned endpoint:

You're now viewing the setup for this endpoint, with general details in the upper panel and a series of tabs in the lower panel:

Step 2 Change the name to reflect the purpose of this endpoint (the name entered here is displayed to users when configuring connector shapes in process flows) - for example:

Step 3 Update remaining fields in this panel, if necessary:

If you started this task by cloning a similar endpoint, you may not need to change the entity type or direction. For further information about these options, please see our connector builder documentation.

Step 4 Move down to the lower panel (where the authentication tab is displayed) and toggle token authentication to on:

...you'll see a confirmation message when this authentication method is added:

Step 5 Not all endpoints require variables - check the Shopify API documentation and if needed, click the variables tab to add them:

For further information about these options, please see our connector builder documentation.

Step 6 Click the URL tab and set the following options:

Option
Required setting

HTTP method

PUT

URL

https://{store_name}.myshopify.com/admin/api/2025-01/graphql.json

For example:

Shopify GraphQL queries are executed by sending POST HTTP requests to the following endpoint:

https://{store_name}.myshopify.com/admin/api/2025-01/graphql.json.

This URL includes a {store_name} variable that is resolved from the Shopify store name that's entered when instances for this connector are added and used in process flows - you don't need to change anything here.

Step 7 Click the header tab. Unless the Shopify API documentation states otherwise, header information is always the same, so the details shown for your cloned endpoint don't need to be changed:

For reference, the header includes one parameter named X-Shopify-Access-Token, with a value set to {{token}}.

Step 8 Click the body tab - here you'll find the GraphQL query for the endpoint you cloned earlier:

...from here, you can edit the existing query as needed.

Queries for existing GraphQL endpoints (installed with the Shopify connector) include pagination settings - for example:

{ customers(first: 50 query: $query {{pagination_cursor}}) { pageInfo {startCursor hasPreviousPage hasNextPage endCursor}

These work in conjunction with our predefined GraphQL cursor pagination method, and can be updated as required. You can learn more about GraphQL pagination in Shopify's API documentation.

Step 9 Schemas aren't required for GraphQL queries. With so much flexibility to control what fields are returned by queries, adding a schema can often become confusing and difficult to maintain - general (though not mandatory) advice is to ignore the schema tab for GraphQL endpoints.

Step 10 Click the pagination tab and set the following options:

Option
Required setting

Pagination method

GraphQL Cursor

EndCursor path

data.entity.pageInfo.endCursor/graphql.json Replace the entity element with the data element you're querying - for example: data.customers.pageInfo.endCursor

HasNextPage path

data.entity.pageInfo.hasNextPage Replace the entity element with the data element you're querying - for example: data.customers.pageInfo.hasNextPage

For example:

Step 11 Save changes to return to the list of endpoints:

Last updated