customerquery
query
2024-10latest
Returns a Customer resource by ID.
Arguments
The ID of the Customer to return.
Was this section helpful?
Customer possible returns
Represents information about a customer of the shop, such as the customer's contact details, their order history, and whether they've agreed to receive marketing material by email.
Caution: Only use this data if it's required for your app's functionality. Shopify will restrict access to scopes for apps that don't have a legitimate use for the associated data.
Was this section helpful?
Code examples for QUERY: customer
Query Reference for QUERY: customer
"{\n customer(id) {\n # Customer fields\n }\n}"
Input Reference for QUERY: customer
Schema Reference for QUERY: customer
Display Examples for QUERY: customer
[ { "example": { "type_name": "customer", "title": "Get a customer by ID", "description": "The following query retrieves the customer with the associated ID. It returns the customer fields specified in the query.\n", "query_string": "query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n id\n firstName\n lastName\n email\n phone\n numberOfOrders\n amountSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n note\n verifiedEmail\n validEmailAddress\n tags\n lifetimeDuration\n defaultAddress {\n formattedArea\n address1\n }\n addresses {\n address1\n }\n image {\n src\n }\n canDelete\n }\n}", "query_arguments": { "id": "gid://shopify/Customer/544365967" }, "response": { "data": { "customer": { "id": "gid://shopify/Customer/544365967", "firstName": "Bob", "lastName": "Bobsen", "email": "bob@example.com", "phone": "+13125551212", "numberOfOrders": "25", "amountSpent": { "amount": "8305.6", "currencyCode": "USD" }, "createdAt": "2005-06-15T15:57:11Z", "updatedAt": "2005-06-16T15:57:11Z", "note": null, "verifiedEmail": true, "validEmailAddress": true, "tags": [ "Bob", "Canadian", "Léon", "Noël" ], "lifetimeDuration": "about 19 years", "defaultAddress": { "formattedArea": "Ottawa ON, Canada", "address1": "123 Amoebobacterieae St" }, "addresses": [ { "address1": "123 Amoebobacterieae St" } ], "image": { "src": "https://cdn.shopify.com/proxy/d02a582792c73c48b4b62a95f42bcbf6eff91c5d232efb2057ca4c41005e4728/www.gravatar.com/avatar/4b9bb80620f03eb3719e0a061c14283d.jpg?s=2048&d=https%3A%2F%2Fcdn.shopify.com%2Fshopifycloud%2Fshopify%2Fassets%2Fadmin%2Fcustomers%2Fpolaris%2Favatar-2-a0ee6e3fb3ae515b66b68388b265e5bd1e90646c4c72d59170518f45351e668b.png" }, "canDelete": false } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { customer(id: \\\"gid://shopify/Customer/544365967\\\") { id firstName lastName email phone numberOfOrders amountSpent { amount currencyCode } createdAt updatedAt note verifiedEmail validEmailAddress tags lifetimeDuration defaultAddress { formattedArea address1 } addresses { address1 } image { src } canDelete } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n id\n firstName\n lastName\n email\n phone\n numberOfOrders\n amountSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n note\n verifiedEmail\n validEmailAddress\n tags\n lifetimeDuration\n defaultAddress {\n formattedArea\n address1\n }\n addresses {\n address1\n }\n image {\n src\n }\n canDelete\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n id\n firstName\n lastName\n email\n phone\n numberOfOrders\n amountSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n note\n verifiedEmail\n validEmailAddress\n tags\n lifetimeDuration\n defaultAddress {\n formattedArea\n address1\n }\n addresses {\n address1\n }\n image {\n src\n }\n canDelete\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n id\n firstName\n lastName\n email\n phone\n numberOfOrders\n amountSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n note\n verifiedEmail\n validEmailAddress\n tags\n lifetimeDuration\n defaultAddress {\n formattedArea\n address1\n }\n addresses {\n address1\n }\n image {\n src\n }\n canDelete\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n id\n firstName\n lastName\n email\n phone\n numberOfOrders\n amountSpent {\n amount\n currencyCode\n }\n createdAt\n updatedAt\n note\n verifiedEmail\n validEmailAddress\n tags\n lifetimeDuration\n defaultAddress {\n formattedArea\n address1\n }\n addresses {\n address1\n }\n image {\n src\n }\n canDelete\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "customer", "title": "Get a customer's name, email, and default address", "description": "The following query retrieves the customer with the associated ID. It returns the customer's name, email and default address specified by the fields in the query.\n", "query_string": "query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n email\n firstName\n lastName\n defaultAddress {\n address1\n city\n province\n zip\n country\n }\n }\n}", "query_arguments": { "id": "gid://shopify/Customer/544365967" }, "response": { "data": { "customer": { "email": "bob@example.com", "firstName": "Bob", "lastName": "Bobsen", "defaultAddress": { "address1": "123 Amoebobacterieae St", "city": "Ottawa", "province": "Ontario", "zip": "K2P0V6", "country": "Canada" } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { customer(id: \\\"gid://shopify/Customer/544365967\\\") { email firstName lastName defaultAddress { address1 city province zip country } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n email\n firstName\n lastName\n defaultAddress {\n address1\n city\n province\n zip\n country\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n email\n firstName\n lastName\n defaultAddress {\n address1\n city\n province\n zip\n country\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n email\n firstName\n lastName\n defaultAddress {\n address1\n city\n province\n zip\n country\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n email\n firstName\n lastName\n defaultAddress {\n address1\n city\n province\n zip\n country\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "customer", "title": "Get all a customer's fields and connections", "description": "The following query retrieves the customer with the associated ID. It returns all of the available fields and connections specified in the query.\n", "query_string": "query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n addresses(first: 5) {\n address1\n }\n canDelete\n createdAt\n defaultAddress {\n address1\n }\n displayName\n email\n events(first: 5) {\n edges {\n node {\n message\n }\n }\n }\n firstName\n id\n image {\n id\n }\n lastName\n legacyResourceId\n lifetimeDuration\n mergeable {\n isMergeable\n reason\n }\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n note\n orders(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n numberOfOrders\n phone\n state\n tags\n taxExempt\n amountSpent {\n amount\n }\n updatedAt\n validEmailAddress\n verifiedEmail\n }\n}", "query_arguments": { "id": "gid://shopify/Customer/544365967" }, "response": { "data": { "customer": { "addresses": [ { "address1": "123 Amoebobacterieae St" } ], "canDelete": false, "createdAt": "2005-06-15T15:57:11Z", "defaultAddress": { "address1": "123 Amoebobacterieae St" }, "displayName": "Bob Bobsen", "email": "bob@example.com", "events": { "edges": [] }, "firstName": "Bob", "id": "gid://shopify/Customer/544365967", "image": { "id": null }, "lastName": "Bobsen", "legacyResourceId": "544365967", "lifetimeDuration": "about 19 years", "mergeable": { "isMergeable": false, "reason": "Bob Bobsen is scheduled for redaction or has been redacted and can’t be merged." }, "metafield": null, "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/749520593" } } ] }, "note": null, "orders": { "edges": [ { "node": { "id": "gid://shopify/Order/116757651" } }, { "node": { "id": "gid://shopify/Order/126216516" } }, { "node": { "id": "gid://shopify/Order/148977776" } }, { "node": { "id": "gid://shopify/Order/215577410" } }, { "node": { "id": "gid://shopify/Order/235240302" } } ] }, "numberOfOrders": "25", "phone": "+13125551212", "state": "ENABLED", "tags": [ "Bob", "Canadian", "Léon", "Noël" ], "taxExempt": false, "amountSpent": { "amount": "8305.6" }, "updatedAt": "2005-06-16T15:57:11Z", "validEmailAddress": true, "verifiedEmail": true } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { customer(id: \\\"gid://shopify/Customer/544365967\\\") { addresses(first: 5) { address1 } canDelete createdAt defaultAddress { address1 } displayName email events(first: 5) { edges { node { message } } } firstName id image { id } lastName legacyResourceId lifetimeDuration mergeable { isMergeable reason } metafield(key: \\\"app_key\\\", namespace: \\\"affiliates\\\") { description } metafields(first: 5) { edges { node { id } } } note orders(first: 5) { edges { node { id } } } numberOfOrders phone state tags taxExempt amountSpent { amount } updatedAt validEmailAddress verifiedEmail } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n addresses(first: 5) {\n address1\n }\n canDelete\n createdAt\n defaultAddress {\n address1\n }\n displayName\n email\n events(first: 5) {\n edges {\n node {\n message\n }\n }\n }\n firstName\n id\n image {\n id\n }\n lastName\n legacyResourceId\n lifetimeDuration\n mergeable {\n isMergeable\n reason\n }\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n note\n orders(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n numberOfOrders\n phone\n state\n tags\n taxExempt\n amountSpent {\n amount\n }\n updatedAt\n validEmailAddress\n verifiedEmail\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n addresses(first: 5) {\n address1\n }\n canDelete\n createdAt\n defaultAddress {\n address1\n }\n displayName\n email\n events(first: 5) {\n edges {\n node {\n message\n }\n }\n }\n firstName\n id\n image {\n id\n }\n lastName\n legacyResourceId\n lifetimeDuration\n mergeable {\n isMergeable\n reason\n }\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n note\n orders(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n numberOfOrders\n phone\n state\n tags\n taxExempt\n amountSpent {\n amount\n }\n updatedAt\n validEmailAddress\n verifiedEmail\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n addresses(first: 5) {\n address1\n }\n canDelete\n createdAt\n defaultAddress {\n address1\n }\n displayName\n email\n events(first: 5) {\n edges {\n node {\n message\n }\n }\n }\n firstName\n id\n image {\n id\n }\n lastName\n legacyResourceId\n lifetimeDuration\n mergeable {\n isMergeable\n reason\n }\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n note\n orders(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n numberOfOrders\n phone\n state\n tags\n taxExempt\n amountSpent {\n amount\n }\n updatedAt\n validEmailAddress\n verifiedEmail\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n customer(id: \"gid://shopify/Customer/544365967\") {\n addresses(first: 5) {\n address1\n }\n canDelete\n createdAt\n defaultAddress {\n address1\n }\n displayName\n email\n events(first: 5) {\n edges {\n node {\n message\n }\n }\n }\n firstName\n id\n image {\n id\n }\n lastName\n legacyResourceId\n lifetimeDuration\n mergeable {\n isMergeable\n reason\n }\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n note\n orders(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n numberOfOrders\n phone\n state\n tags\n taxExempt\n amountSpent {\n amount\n }\n updatedAt\n validEmailAddress\n verifiedEmail\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "customer", "title": "Get the email, name, and account creation date of three customers using a fragment", "description": "The following query retrieves three specific customers with the associated IDs, which are aliased to the names provided. It returns the customer fields specified in the fragment.\n", "query_string": "query {\n Bob: customer(id: \"gid://shopify/Customer/544365967\") {\n ...customerProfile\n }\n Jane: customer(id: \"gid://shopify/Customer/567375318\") {\n ...customerProfile\n }\n Jenny: customer(id: \"gid://shopify/Customer/56501169\") {\n ...customerProfile\n }\n}\n\nfragment customerProfile on Customer {\n firstName\n lastName\n email\n createdAt\n}", "query_arguments": { "id": "gid://shopify/Customer/544365967" }, "response": { "data": { "Bob": { "firstName": "Bob", "lastName": "Bobsen", "email": "bob@example.com", "createdAt": "2005-06-15T15:57:11Z" }, "Jane": { "firstName": "Jane", "lastName": "Smith", "email": "janesmith@b2b.example.com", "createdAt": "2024-09-12T01:05:24Z" }, "Jenny": { "firstName": "Jenny", "lastName": "Test", "email": "jennytest@b2b.example.com", "createdAt": "2024-09-12T01:05:24Z" } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { Bob: customer(id: \\\"gid://shopify/Customer/544365967\\\") { ...customerProfile } Jane: customer(id: \\\"gid://shopify/Customer/567375318\\\") { ...customerProfile } Jenny: customer(id: \\\"gid://shopify/Customer/56501169\\\") { ...customerProfile } } fragment customerProfile on Customer { firstName lastName email createdAt }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n Bob: customer(id: \"gid://shopify/Customer/544365967\") {\n ...customerProfile\n }\n Jane: customer(id: \"gid://shopify/Customer/567375318\") {\n ...customerProfile\n }\n Jenny: customer(id: \"gid://shopify/Customer/56501169\") {\n ...customerProfile\n }\n }\n \n fragment customerProfile on Customer {\n firstName\n lastName\n email\n createdAt\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n Bob: customer(id: \"gid://shopify/Customer/544365967\") {\n ...customerProfile\n }\n Jane: customer(id: \"gid://shopify/Customer/567375318\") {\n ...customerProfile\n }\n Jenny: customer(id: \"gid://shopify/Customer/56501169\") {\n ...customerProfile\n }\n }\n \n fragment customerProfile on Customer {\n firstName\n lastName\n email\n createdAt\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n Bob: customer(id: \"gid://shopify/Customer/544365967\") {\n ...customerProfile\n }\n Jane: customer(id: \"gid://shopify/Customer/567375318\") {\n ...customerProfile\n }\n Jenny: customer(id: \"gid://shopify/Customer/56501169\") {\n ...customerProfile\n }\n }\n \n fragment customerProfile on Customer {\n firstName\n lastName\n email\n createdAt\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n Bob: customer(id: \"gid://shopify/Customer/544365967\") {\n ...customerProfile\n }\n Jane: customer(id: \"gid://shopify/Customer/567375318\") {\n ...customerProfile\n }\n Jenny: customer(id: \"gid://shopify/Customer/56501169\") {\n ...customerProfile\n }\n }\n \n fragment customerProfile on Customer {\n firstName\n lastName\n email\n createdAt\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "customer", "title": "Get the first five line items of the customer's last order", "description": "The following query retrieves the customer with the associated ID. It returns details about the last 5 line items associated with the customer's most recent order.\n", "query_string": "query {\n customer(id: \"gid://shopify/Customer/624407574\") {\n lastOrder {\n lineItems(first: 5) {\n edges {\n node {\n name\n quantity\n }\n }\n }\n }\n }\n}", "query_arguments": { "id": "gid://shopify/Customer/624407574" }, "response": { "data": { "customer": { "lastOrder": { "lineItems": { "edges": [ { "node": { "name": "Draft - 151cm", "quantity": 1 } } ] } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { customer(id: \\\"gid://shopify/Customer/624407574\\\") { lastOrder { lineItems(first: 5) { edges { node { name quantity } } } } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n customer(id: \"gid://shopify/Customer/624407574\") {\n lastOrder {\n lineItems(first: 5) {\n edges {\n node {\n name\n quantity\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n customer(id: \"gid://shopify/Customer/624407574\") {\n lastOrder {\n lineItems(first: 5) {\n edges {\n node {\n name\n quantity\n }\n }\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n customer(id: \"gid://shopify/Customer/624407574\") {\n lastOrder {\n lineItems(first: 5) {\n edges {\n node {\n name\n quantity\n }\n }\n }\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n customer(id: \"gid://shopify/Customer/624407574\") {\n lastOrder {\n lineItems(first: 5) {\n edges {\n node {\n name\n quantity\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/624407574\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "customer", "title": "Get the merge status of a customer", "description": "Retrieve the merge status of a customer.\n", "query_string": "query {\n customer(id: \"gid://shopify/Customer/105906728\") {\n mergeable {\n isMergeable\n reason\n errorFields\n mergeInProgress {\n jobId\n status\n resultingCustomerId\n customerMergeErrors {\n errorFields\n message\n }\n }\n }\n }\n}", "query_arguments": { "id": "gid://shopify/Customer/105906728" }, "response": { "data": { "customer": { "mergeable": { "isMergeable": false, "reason": "John Smith is scheduled for redaction or has been redacted and can’t be merged.", "errorFields": [ "REDACTED_AT" ], "mergeInProgress": null } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { customer(id: \\\"gid://shopify/Customer/105906728\\\") { mergeable { isMergeable reason errorFields mergeInProgress { jobId status resultingCustomerId customerMergeErrors { errorFields message } } } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n customer(id: \"gid://shopify/Customer/105906728\") {\n mergeable {\n isMergeable\n reason\n errorFields\n mergeInProgress {\n jobId\n status\n resultingCustomerId\n customerMergeErrors {\n errorFields\n message\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n customer(id: \"gid://shopify/Customer/105906728\") {\n mergeable {\n isMergeable\n reason\n errorFields\n mergeInProgress {\n jobId\n status\n resultingCustomerId\n customerMergeErrors {\n errorFields\n message\n }\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n customer(id: \"gid://shopify/Customer/105906728\") {\n mergeable {\n isMergeable\n reason\n errorFields\n mergeInProgress {\n jobId\n status\n resultingCustomerId\n customerMergeErrors {\n errorFields\n message\n }\n }\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n customer(id: \"gid://shopify/Customer/105906728\") {\n mergeable {\n isMergeable\n reason\n errorFields\n mergeInProgress {\n jobId\n status\n resultingCustomerId\n customerMergeErrors {\n errorFields\n message\n }\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/105906728\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "customer", "title": "Get two specific customers by their ID using aliases", "description": "The following query retrieves two specific customers with the associated IDs. It returns the customer fields specified in the query, aliased to the names provided.\n", "query_string": "query {\n bob: customer(id: \"gid://shopify/Customer/544365967\") {\n firstName\n lastName\n email\n }\n john: customer(id: \"gid://shopify/Customer/105906728\") {\n firstName\n lastName\n email\n }\n}", "query_arguments": { "id": "gid://shopify/Customer/544365967" }, "response": { "data": { "bob": { "firstName": "Bob", "lastName": "Bobsen", "email": "bob@example.com" }, "john": { "firstName": "John", "lastName": "Smith", "email": "johnsmith@example.com" } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/customers/test/unit/graph_api/admin/customer_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { bob: customer(id: \\\"gid://shopify/Customer/544365967\\\") { firstName lastName email } john: customer(id: \\\"gid://shopify/Customer/105906728\\\") { firstName lastName email } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n bob: customer(id: \"gid://shopify/Customer/544365967\") {\n firstName\n lastName\n email\n }\n john: customer(id: \"gid://shopify/Customer/105906728\") {\n firstName\n lastName\n email\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n bob: customer(id: \"gid://shopify/Customer/544365967\") {\n firstName\n lastName\n email\n }\n john: customer(id: \"gid://shopify/Customer/105906728\") {\n firstName\n lastName\n email\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n bob: customer(id: \"gid://shopify/Customer/544365967\") {\n firstName\n lastName\n email\n }\n john: customer(id: \"gid://shopify/Customer/105906728\") {\n firstName\n lastName\n email\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n bob: customer(id: \"gid://shopify/Customer/544365967\") {\n firstName\n lastName\n email\n }\n john: customer(id: \"gid://shopify/Customer/105906728\") {\n firstName\n lastName\n email\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the Customer to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Customer/544365967\"", "typeKind": "QUERY" } ] } ]