GraphQL Query Examples

View example queries that show how to use Square GraphQL for common reporting scenarios.

Link to section

Overview

Square GraphQL lets you query for data across supported Square graphs. The following query examples show common reporting scenarios that demonstrate the power and ease of using GraphQL. You can copy the examples and run them in GraphQL Explorer.

The examples use variables and include fields for pagination. To page through data, provide the cursor returned in the response as the before or after argument in your next query. Some examples use aliases to rename response fields.

To get the merchant ID for the merchantId variable, run the following query in GraphQL Explorer:

{ currentMerchant { id }

Note

To learn about GraphQL Explorer features and how to get set up to run queries, see GraphQL Explorer. GraphQL Explorer also provides a set of sample queries that you can run.

Link to section

Get payment history for a customer

The following example returns information about in-progress or completed payments made by a customer within a specified time range. This query also retrieves any refunds for the payment.

This example uses a refundOrderId alias to rename the orderId field in the response when it applies to orders created for a refund.

Link to section

Get processing fees for completed orders

The following example returns the processing fees associated with completed orders that were closed in a specified time range. This query retrieves the fees from the Payment object that corresponds to the tender.

This example uses orderAmount and feeAmount aliases to rename the amountMoney fields in the response for easier identification.

Link to section

Get application fees for completed payments

The following example returns application fees earned for completed payments and deducted for refunds during a specified time period.

You should run this query using the access token and merchant ID of each Square seller account you want to report on.

This example uses a refundOrderId alias to rename the orderId field in the response when it applies to orders created for a refund.

Link to section

Get order details

The following example retrieves details about an order, including information about the associated customer, catalog items, and payment. Sellers might run this query if they want to collect order data and feed it into a different system or analytics software for reporting purposes.

Link to section

Get payout entries for CHARGE and REFUND fees

The following example retrieves payout entries that contain CHARGE and REFUND fees for card payments during a specified time period.

This example queries the payoutEntries entry point.

Link to section

See also