Get a metafield attached to a location
Description
Get the metafield value identified by `my_fields.hours` on a specific location.
Query
query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
location(id: $ownerId) {
hours: metafield(namespace: $namespace, key: $key) {
value
}
}
}
Variables
{
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } }",
"variables": {
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
location(id: $ownerId) {
hours: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
{
variables: {
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
location(id: $ownerId) {
hours: metafield(namespace: $namespace, key: $key) {
value
}
}
}
QUERY
variables = {
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
location(id: $ownerId) {
hours: metafield(namespace: $namespace, key: $key) {
value
}
}
}`,
"variables": {
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
},
},
});
Shopify CLI
shopify app execute \
--query \
'query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
location(id: $ownerId) {
hours: metafield(namespace: $namespace, key: $key) {
value
}
}
}' \
--variables \
'{
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-04/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {
location(id: $ownerId) {
hours: metafield(namespace: $namespace, key: $key) {
value
}
}
}
`,
variables: {
"namespace": "my_fields",
"key": "hours",
"ownerId": "gid://shopify/Location/346779380"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"location": {
"hours": {
"value": "Open daily 9AM-5PM"
}
}
}
Get metafields attached to a location
Description
Get a page of metafields attached to a specific location.
Query
query LocationMetafields($ownerId: ID!) {
location(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}
Variables
{
"ownerId": "gid://shopify/Location/346779380"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }",
"variables": {
"ownerId": "gid://shopify/Location/346779380"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query LocationMetafields($ownerId: ID!) {
location(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}`,
{
variables: {
"ownerId": "gid://shopify/Location/346779380"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 LocationMetafields($ownerId: ID!) {
location(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}
QUERY
variables = {
"ownerId": "gid://shopify/Location/346779380"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query LocationMetafields($ownerId: ID!) {
location(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}`,
"variables": {
"ownerId": "gid://shopify/Location/346779380"
},
},
});
Shopify CLI
shopify app execute \
--query \
'query LocationMetafields($ownerId: ID!) {
location(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}' \
--variables \
'{
"ownerId": "gid://shopify/Location/346779380"
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-04/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
query LocationMetafields($ownerId: ID!) {
location(id: $ownerId) {
metafields(first: 3) {
edges {
node {
namespace
key
value
}
}
}
}
}
`,
variables: {
"ownerId": "gid://shopify/Location/346779380"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"location": {
"metafields": {
"edges": [
{
"node": {
"namespace": "my_fields",
"key": "hours",
"value": "Open daily 9AM-5PM"
}
}
]
}
}
}
Get pinned metafield definitions associated with a location
Description
Get names and types of the first page of pinned metafield definitions associated with a location.
Query
query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {
location(id: $ownerId) {
metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {
edges {
node {
name
namespace
key
type {
name
}
}
}
}
}
}
Variables
{
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { location(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }",
"variables": {
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {
location(id: $ownerId) {
metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {
edges {
node {
name
namespace
key
type {
name
}
}
}
}
}
}`,
{
variables: {
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {
location(id: $ownerId) {
metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {
edges {
node {
name
namespace
key
type {
name
}
}
}
}
}
}
QUERY
variables = {
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {
location(id: $ownerId) {
metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {
edges {
node {
name
namespace
key
type {
name
}
}
}
}
}
}`,
"variables": {
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
},
},
});
Shopify CLI
shopify app execute \
--query \
'query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {
location(id: $ownerId) {
metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {
edges {
node {
name
namespace
key
type {
name
}
}
}
}
}
}' \
--variables \
'{
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-04/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {
location(id: $ownerId) {
metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {
edges {
node {
name
namespace
key
type {
name
}
}
}
}
}
}
`,
variables: {
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Location/346779380",
"first": 10,
"sortKey": "PINNED_POSITION"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"location": {
"metafieldDefinitions": {
"edges": [
{
"node": {
"name": "Additional Notes",
"namespace": "my_fields",
"key": "notes",
"type": {
"name": "single_line_text_field"
}
}
},
{
"node": {
"name": "Operating Since",
"namespace": "my_fields",
"key": "operating_since",
"type": {
"name": "date"
}
}
}
]
}
}
}
Retrieve a list of inventory levels for a location
Query
query LocationInventoryLevelList($id: ID!) {
location(id: $id) {
inventoryLevels(first: 10) {
nodes {
item {
id
}
location {
id
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}
Variables
{
"id": "gid://shopify/Location/346779380"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: [\"available\"]) { name quantity } } } } }",
"variables": {
"id": "gid://shopify/Location/346779380"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query LocationInventoryLevelList($id: ID!) {
location(id: $id) {
inventoryLevels(first: 10) {
nodes {
item {
id
}
location {
id
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}`,
{
variables: {
"id": "gid://shopify/Location/346779380"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 LocationInventoryLevelList($id: ID!) {
location(id: $id) {
inventoryLevels(first: 10) {
nodes {
item {
id
}
location {
id
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}
QUERY
variables = {
"id": "gid://shopify/Location/346779380"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query LocationInventoryLevelList($id: ID!) {
location(id: $id) {
inventoryLevels(first: 10) {
nodes {
item {
id
}
location {
id
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}`,
"variables": {
"id": "gid://shopify/Location/346779380"
},
},
});
Shopify CLI
shopify app execute \
--query \
'query LocationInventoryLevelList($id: ID!) {
location(id: $id) {
inventoryLevels(first: 10) {
nodes {
item {
id
}
location {
id
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}' \
--variables \
'{
"id": "gid://shopify/Location/346779380"
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-04/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
query LocationInventoryLevelList($id: ID!) {
location(id: $id) {
inventoryLevels(first: 10) {
nodes {
item {
id
}
location {
id
}
quantities(names: ["available"]) {
name
quantity
}
}
}
}
}
`,
variables: {
"id": "gid://shopify/Location/346779380"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"location": {
"inventoryLevels": {
"nodes": [
{
"item": {
"id": "gid://shopify/InventoryItem/113711323"
},
"location": {
"id": "gid://shopify/Location/346779380"
},
"quantities": [
{
"name": "available",
"quantity": 8
}
]
},
{
"item": {
"id": "gid://shopify/InventoryItem/30322695"
},
"location": {
"id": "gid://shopify/Location/346779380"
},
"quantities": [
{
"name": "available",
"quantity": 2
}
]
}
]
}
}
}
Retrieve a single location by its ID
Query
query LocationShow($id: ID!) {
location(id: $id) {
id
name
fulfillmentService {
handle
}
address {
address1
address2
city
country
countryCode
province
provinceCode
zip
}
fulfillsOnlineOrders
hasActiveInventory
isActive
}
}
Variables
{
"id": "gid://shopify/Location/346779380"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }",
"variables": {
"id": "gid://shopify/Location/346779380"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query LocationShow($id: ID!) {
location(id: $id) {
id
name
fulfillmentService {
handle
}
address {
address1
address2
city
country
countryCode
province
provinceCode
zip
}
fulfillsOnlineOrders
hasActiveInventory
isActive
}
}`,
{
variables: {
"id": "gid://shopify/Location/346779380"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
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 LocationShow($id: ID!) {
location(id: $id) {
id
name
fulfillmentService {
handle
}
address {
address1
address2
city
country
countryCode
province
provinceCode
zip
}
fulfillsOnlineOrders
hasActiveInventory
isActive
}
}
QUERY
variables = {
"id": "gid://shopify/Location/346779380"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `query LocationShow($id: ID!) {
location(id: $id) {
id
name
fulfillmentService {
handle
}
address {
address1
address2
city
country
countryCode
province
provinceCode
zip
}
fulfillsOnlineOrders
hasActiveInventory
isActive
}
}`,
"variables": {
"id": "gid://shopify/Location/346779380"
},
},
});
Shopify CLI
shopify app execute \
--query \
'query LocationShow($id: ID!) {
location(id: $id) {
id
name
fulfillmentService {
handle
}
address {
address1
address2
city
country
countryCode
province
provinceCode
zip
}
fulfillsOnlineOrders
hasActiveInventory
isActive
}
}' \
--variables \
'{
"id": "gid://shopify/Location/346779380"
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-04/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
query LocationShow($id: ID!) {
location(id: $id) {
id
name
fulfillmentService {
handle
}
address {
address1
address2
city
country
countryCode
province
provinceCode
zip
}
fulfillsOnlineOrders
hasActiveInventory
isActive
}
}
`,
variables: {
"id": "gid://shopify/Location/346779380"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"location": {
"id": "gid://shopify/Location/346779380",
"name": "Ottawa Store",
"fulfillmentService": null,
"address": {
"address1": "126 york street",
"address2": "second and third floor",
"city": "ottawa",
"country": "Canada",
"countryCode": "CA",
"province": "Ontario",
"provinceCode": "ON",
"zip": "k1n5t5"
},
"fulfillsOnlineOrders": true,
"hasActiveInventory": true,
"isActive": true
}
}
Returns a Location resource by ID
Description
The following query retrieves the location with the associated ID.
It returns the location fields specified in the query.
Query
query {
location(id: "gid://shopify/Location/346779380") {
id
name
address {
formatted
}
deactivatable
fulfillsOnlineOrders
hasActiveInventory
isActive
shipsInventory
}
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2026-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { location(id: \"gid://shopify/Location/346779380\") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } }"
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
location(id: "gid://shopify/Location/346779380") {
id
name
address {
formatted
}
deactivatable
fulfillsOnlineOrders
hasActiveInventory
isActive
shipsInventory
}
}`,
);
const json = await response.json();
return json.data;
}
Ruby
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 {
location(id: "gid://shopify/Location/346779380") {
id
name
address {
formatted
}
deactivatable
fulfillsOnlineOrders
hasActiveInventory
isActive
shipsInventory
}
}
QUERY
response = client.query(query: query)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
location(id: "gid://shopify/Location/346779380") {
id
name
address {
formatted
}
deactivatable
fulfillsOnlineOrders
hasActiveInventory
isActive
shipsInventory
}
}`,
});
Shopify CLI
shopify app execute \
--query \
'query {
location(id: "gid://shopify/Location/346779380") {
id
name
address {
formatted
}
deactivatable
fulfillsOnlineOrders
hasActiveInventory
isActive
shipsInventory
}
}'
Direct API Access
const response = await fetch('shopify:admin/api/2026-04/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
query {
location(id: "gid://shopify/Location/346779380") {
id
name
address {
formatted
}
deactivatable
fulfillsOnlineOrders
hasActiveInventory
isActive
shipsInventory
}
}
`,
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"location": {
"id": "gid://shopify/Location/346779380",
"name": "Ottawa Store",
"address": {
"formatted": [
"126 york street",
"second and third floor",
"ottawa ON k1n5t5",
"Canada"
]
},
"deactivatable": true,
"fulfillsOnlineOrders": true,
"hasActiveInventory": true,
"isActive": true,
"shipsInventory": false
}
}