Anchor to company
company
query
Returns a Company
object by ID.
Anchor to Possible returnsPossible returns
- Anchor to CompanyCompany•
Represents information about a company which is also a customer of the shop.
Was this section helpful?
- Get a company by its ID
- Get a metafield attached to a company
- Get metafields attached to a company
- Get pinned metafield definitions associated with a company
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
company(id: "gid://shopify/Company/426793626") {
id
name
note
externalId
totalSpent {
amount
currencyCode
}
}
}`,
);
const data = await response.json();
query {
company(id: "gid://shopify/Company/426793626") {
id
name
note
externalId
totalSpent {
amount
currencyCode
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { company(id: \"gid://shopify/Company/426793626\") { id name note externalId totalSpent { amount currencyCode } } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
company(id: "gid://shopify/Company/426793626") {
id
name
note
externalId
totalSpent {
amount
currencyCode
}
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
company(id: "gid://shopify/Company/426793626") {
id
name
note
externalId
totalSpent {
amount
currencyCode
}
}
}`,
});
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
query {
company(id: "gid://shopify/Company/426793626") {
id
name
note
externalId
totalSpent {
amount
currencyCode
}
}
}
QUERY
response = client.query(query: query)
Response
JSON{
"company": {
"id": "gid://shopify/Company/426793626",
"name": "Fancy Pants Inc.",
"note": "test notes",
"externalId": "external_id1",
"totalSpent": {
"amount": "120.0",
"currencyCode": "USD"
}
}
}