Development discussions around Shopify APIs
Hi, I want to get data of customers with ID. I see an example like below code but its same code repeting multiple time, is there any way to call like `Customers(ids: [graphqlid, graphqqlid]){ ...}`
customer1: customer(id:"gid://shopify/Customer/1310260264982") {
displayName
}
customer2: customer(id:"gid://shopify/Customer/1310260789270") {
displayName
}
customer3: customer(id: "gid://shopify/Customer/1310260854806") {
displayName
}
}
Hi,
In case you still have this issue or anybody else is looking for the proper answer, here it goes.
You can query multiple id's like this:
```
{
nodes( ids: [ "gid://shopify/Customer/3781894373511", "gid://shopify/Customer/3903388090503", "gid://shopify/Customer/3903390777479" ] ) {
...on Customer {
displayName
}
}
}
```
Hi,
In case you still have this issue or anybody else is looking for the proper answer, here it goes.
You can query multiple id's like this:
{
nodes( ids: [ "gid://shopify/Customer/3781894373511", "gid://shopify/Customer/3903388090503", "gid://shopify/Customer/3903390777479" ] ) {
...on Customer {
displayName
}
}
}
Hope this helps.
Paul
Hi @Paul_vd_Dool !
Thank you for the example you had provided - are you able to provide a second example that passes the array of IDs as variables?
We are trying to switch from your REST API GET /customers call, which we filter by IDs -
https://shopify.dev/api/admin-rest/2021-10/resources/customer#[get]/admin/api/2021-10/customers.json
To your graphQL customers query, and are facing some difficulties in incorporating variables with nodes.
Any idea how we can achieve this?
Thanks!
Hi @Thalia-Yotpo ,
I've grabbed an example from my app.
query getSubCustomers($ids: [ID!]!) {
nodes(ids: $ids) {
... on Customer {
id
displayName
email
}
}
}
// variables
{
"ids": [
"gid://shopify/Customer/987654321",
"gid://shopify/Customer/123456789"
]
}
I hope this helps.
As a business owner, have you ever wondered when your customer's first impression of yo...
By Skye Jun 6, 2023We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023