Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
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.
User | RANK |
---|---|
5 | |
4 | |
4 | |
3 | |
3 |