Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/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" 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" 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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<\"my_fields\",\n \"key\" => \"hours\",\n \"ownerId\" => \"gid://shopify/Location/346779380\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\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" Graphql 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}"
input: { "namespace": "my_fields", "key": "hours", "ownerId": "gid://shopify/Location/346779380" }
response: { "data": { "location": { "hours": { "value": "Open daily 9AM-5PM" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/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" 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" 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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<\"gid://shopify/Location/346779380\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\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" Graphql 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}"
input: { "ownerId": "gid://shopify/Location/346779380" }
response: { "data": { "location": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "hours", "value": "Open daily 9AM-5PM" } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/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" 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" 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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<\"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" 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" Graphql 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}"
input: { "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" } } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query LocationInventoryLevelList($id: ID!) { location(id: $id) { inventoryLevels(first: 10) { nodes { item { id } location { id } quantities(names: [\\\"available\\\"]) { name quantity } } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Location/346779380\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query LocationInventoryLevelList($id: ID!) {\n location(id: $id) {\n inventoryLevels(first: 10) {\n nodes {\n item {\n id\n }\n location {\n id\n }\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Location/346779380\"\n },\n },\n});\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 LocationInventoryLevelList($id: ID!) {\n location(id: $id) {\n inventoryLevels(first: 10) {\n nodes {\n item {\n id\n }\n location {\n id\n }\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Location/346779380\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<\"gid://shopify/Location/346779380\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query LocationInventoryLevelList($id: ID!) {\n location(id: $id) {\n inventoryLevels(first: 10) {\n nodes {\n item {\n id\n }\n location {\n id\n }\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Location/346779380\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query LocationInventoryLevelList($id: ID!) {\n location(id: $id) {\n inventoryLevels(first: 10) {\n nodes {\n item {\n id\n }\n location {\n id\n }\n quantities(names: [\"available\"]) {\n name\n quantity\n }\n }\n }\n }\n}"
input: { "id": "gid://shopify/Location/346779380" }
response: { "data": { "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 } ] } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query LocationShow($id: ID!) { location(id: $id) { id name fulfillmentService { handle } address { address1 address2 city country countryCode province provinceCode zip } fulfillsOnlineOrders hasActiveInventory isActive } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Location/346779380\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query LocationShow($id: ID!) {\n location(id: $id) {\n id\n name\n fulfillmentService {\n handle\n }\n address {\n address1\n address2\n city\n country\n countryCode\n province\n provinceCode\n zip\n }\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Location/346779380\"\n },\n },\n});\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 LocationShow($id: ID!) {\n location(id: $id) {\n id\n name\n fulfillmentService {\n handle\n }\n address {\n address1\n address2\n city\n country\n countryCode\n province\n provinceCode\n zip\n }\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Location/346779380\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<\"gid://shopify/Location/346779380\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query LocationShow($id: ID!) {\n location(id: $id) {\n id\n name\n fulfillmentService {\n handle\n }\n address {\n address1\n address2\n city\n country\n countryCode\n province\n provinceCode\n zip\n }\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Location/346779380\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query LocationShow($id: ID!) {\n location(id: $id) {\n id\n name\n fulfillmentService {\n handle\n }\n address {\n address1\n address2\n city\n country\n countryCode\n province\n provinceCode\n zip\n }\n fulfillsOnlineOrders\n hasActiveInventory\n isActive\n }\n}"
input: { "id": "gid://shopify/Location/346779380" }
response: { "data": { "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 } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/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" 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" 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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<query([\"query\" => $query]);\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" Graphql query: "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}"
input: null
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 } } }