locationquery
query
2024-10latest
Returns an inventory Location resource by ID.
Arguments
The ID of the location to return. If no ID is provided, the primary location of the Shop is returned.
Was this section helpful?
Location possible returns
Represents the location where the physical good resides.
Was this section helpful?
Code examples for QUERY: location
Query Reference for QUERY: location
"{\n location {\n # Location fields\n }\n}"
Input Reference for QUERY: location
Schema Reference for QUERY: location
Display Examples for QUERY: location
[ { "example": { "type_name": "location", "title": "Get a metafield attached to a location", "description": "Get the metafield value identified by `my_fields.hours` on a specific location.", "query_string": "query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n location(id: $ownerId) {\n hours: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}", "variables": { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" }, "response": { "data": { "location": { "hours": { "value": "Open daily 9AM-5PM" } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "location": "/components/shop_identity/test/unit/graph_api/admin/location_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) { location(id: $ownerId) { hours: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"hours\",\n \"ownerId\": \"gid://shopify/Location/346779380\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n location(id: $ownerId) {\n hours: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"hours\",\n \"ownerId\": \"gid://shopify/Location/346779380\"\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n location(id: $ownerId) {\n hours: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"hours\",\n \"ownerId\": \"gid://shopify/Location/346779380\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n location(id: $ownerId) {\n hours: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"hours\",\n \"ownerId\": \"gid://shopify/Location/346779380\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query LocationMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n location(id: $ownerId) {\n hours: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY;\n\n$variables = [\n \"namespace\" => \"my_fields\",\n \"key\" => \"hours\",\n \"ownerId\" => \"gid://shopify/Location/346779380\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "location", "title": "Get metafields attached to a location", "description": "Get a page of metafields attached to a specific location.", "query_string": "query LocationMetafields($ownerId: ID!) {\n location(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}", "variables": { "ownerId": "gid://shopify/Location/346779380" }, "response": { "data": { "location": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "hours", "value": "Open daily 9AM-5PM" } } ] } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "location": "/components/shop_identity/test/unit/graph_api/admin/location_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query LocationMetafields($ownerId: ID!) { location(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/Location/346779380\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query LocationMetafields($ownerId: ID!) {\n location(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"ownerId\": \"gid://shopify/Location/346779380\"\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query LocationMetafields($ownerId: ID!) {\n location(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"ownerId\": \"gid://shopify/Location/346779380\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query LocationMetafields($ownerId: ID!) {\n location(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"ownerId\": \"gid://shopify/Location/346779380\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query LocationMetafields($ownerId: ID!) {\n location(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"ownerId\" => \"gid://shopify/Location/346779380\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "location", "title": "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_string": "query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n location(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n}", "variables": { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/Location/346779380", "first": 10, "sortKey": "PINNED_POSITION" }, "response": { "data": { "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" } } } ] } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "location": "/components/shop_identity/test/unit/graph_api/admin/location_test.rb", "maximum_api_version": null, "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } } }\",\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Location/346779380\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n location(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Location/346779380\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n location(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Location/346779380\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n location(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Location/346779380\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query LocationMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n location(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"pinnedStatus\" => \"PINNED\",\n \"ownerId\" => \"gid://shopify/Location/346779380\",\n \"first\" => 10,\n \"sortKey\" => \"PINNED_POSITION\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [] }, { "example": { "type_name": "location", "title": "Returns a Location resource by ID", "description": "The following query retrieves the location with the associated ID.\nIt returns the location fields specified in the query.\n", "query_string": "query {\n location(id: \"gid://shopify/Location/346779380\") {\n id\n name\n address {\n formatted\n }\n deactivatable\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n shipsInventory\n }\n}", "query_arguments": { "id": "gid://shopify/Location/346779380" }, "response": { "data": { "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 } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/shop_identity/test/unit/graph_api/admin/location_test.rb", "curl_example": "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { location(id: \\\"gid://shopify/Location/346779380\\\") { id name address { formatted } deactivatable fulfillsOnlineOrders hasActiveInventory isActive shipsInventory } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n location(id: \"gid://shopify/Location/346779380\") {\n id\n name\n address {\n formatted\n }\n deactivatable\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n shipsInventory\n }\n }`,\n);\n\nconst data = await response.json();\n", "ruby_example": "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n location(id: \"gid://shopify/Location/346779380\") {\n id\n name\n address {\n formatted\n }\n deactivatable\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n shipsInventory\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n location(id: \"gid://shopify/Location/346779380\") {\n id\n name\n address {\n formatted\n }\n deactivatable\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n shipsInventory\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n location(id: \"gid://shopify/Location/346779380\") {\n id\n name\n address {\n formatted\n }\n deactivatable\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n shipsInventory\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the location to return. If no ID is provided, the primary location of the Shop is returned.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": false }, "defaultValue": null, "typeSignature": "ID", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/Location/346779380\"", "typeKind": "QUERY" } ] } ]