am trying to query the customer details with shopify graphql
specifically the location of the company this customer is assigned to.
the green circled item
What should be the graph ql query ?
Thank you so much.
I’d be thinking something like
query MyQuery {
customers(first: 10) {
nodes {
displayName
companyContactProfiles {
title
company {
name
locations(first: 10) {
nodes {
shippingAddress {
address1
companyName
city
}
}
}
}
}
}
}
}
but what if the company have multiple location ?
which one of those location will be assigned to the customer ?
Apologies for not properly phrasing my question.
Example
Company 1
Location 1Location 2Location 3Customer 1
Location 1 of company Company 1 with Ordering onlyWhat i want is Locations assigned to Customer 1
{
customer(id: "gid://shopify/Customer/customer1") {
displayName
companyContactProfiles {
company {
locations(first: 10) {
edges {
node {
id
name
}
}
}
}
}
}
}
this returns
"customer": {
"companyContactProfiles": [
"displayName":"Customer1"
{
"company": {
"locations": {
"nodes": [
{
"id": "gid://shopify/CompanyLocation/location1",
"name": "Location 1"
},
{
"id": "gid://shopify/CompanyLocation/location2",
"name": "Location 2"
},
{
"id": "gid://shopify/CompanyLocation/location3",
"name": "Location 3"
},
]
}
}
}
]
}
this query returns all the locations of Company 1
i just saw another property called roleAssignments which seems to be behaving the way i want
so i ran this query
{
customer(id: "gid://shopify/Customer/customer1") {
displayName
companyContactProfiles {
roleAssignments(first: 2) {
nodes {
companyLocation{
name
}
role {
name
}
}
}
}
}
}
and it gave me
"customer": {
"displayName": "Customer 1",
"companyContactProfiles": [
{
"roleAssignments": {
"nodes": [
{
"companyLocation": {
"name": "Location 1"
},
"role": {
"name": "Ordering only"
}
}
]
}
}
]
}
Thank you so much for responding and looking into it
off sitewide
July sale — 45% off at checkout, applied automatically. Valid for 60 minutes. One per customer.
Offer ends in