Version: unstable
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation { locationAdd(input: {name: \\\"New York Warehouses\\\", address: {address1: \\\"101 Liberty Street\\\", city: \\\"New York\\\", provinceCode: \\\"NY\\\", countryCode: US, zip: \\\"10006\\\"}, fulfillsOnlineOrders: true}) { location { id name address { address1 provinceCode countryCode zip } fulfillsOnlineOrders } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `mutation {\n locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n location {\n id\n name\n address {\n address1\n provinceCode\n countryCode\n zip\n }\n fulfillsOnlineOrders\n }\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 mutation {\n locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n location {\n id\n name\n address {\n address1\n provinceCode\n countryCode\n zip\n }\n fulfillsOnlineOrders\n }\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\n mutation {\n locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n location {\n id\n name\n address {\n address1\n provinceCode\n countryCode\n zip\n }\n fulfillsOnlineOrders\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation {\n locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n location {\n id\n name\n address {\n address1\n provinceCode\n countryCode\n zip\n }\n fulfillsOnlineOrders\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "mutation {\n locationAdd(input: {name: \"New York Warehouses\", address: {address1: \"101 Liberty Street\", city: \"New York\", provinceCode: \"NY\", countryCode: US, zip: \"10006\"}, fulfillsOnlineOrders: true}) {\n location {\n id\n name\n address {\n address1\n provinceCode\n countryCode\n zip\n }\n fulfillsOnlineOrders\n }\n }\n}"
input: null
response: { "data": { "locationAdd": { "location": { "id": "gid://shopify/Location/1072404546", "name": "New York Warehouses", "address": { "address1": "101 Liberty Street", "provinceCode": "NY", "countryCode": "US", "zip": "10006" }, "fulfillsOnlineOrders": true } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation createLocationMetafields($input: LocationAddInput!) { locationAdd(input: $input) { location { id metafields(first: 3) { edges { node { id namespace key value } } } } userErrors { message field } } }\",\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"delivery_type\",\n \"type\": \"single_line_text_field\",\n \"value\": \"local\"\n }\n ],\n \"name\": \"Warehouse\",\n \"address\": {\n \"countryCode\": \"CA\"\n }\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation createLocationMetafields($input: LocationAddInput!) {\n locationAdd(input: $input) {\n location {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"delivery_type\",\n \"type\": \"single_line_text_field\",\n \"value\": \"local\"\n }\n ],\n \"name\": \"Warehouse\",\n \"address\": {\n \"countryCode\": \"CA\"\n }\n }\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 mutation createLocationMetafields($input: LocationAddInput!) {\n locationAdd(input: $input) {\n location {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"metafields\": [{\"namespace\"=>\"my_field\", \"key\"=>\"delivery_type\", \"type\"=>\"single_line_text_field\", \"value\"=>\"local\"}],\n \"name\": \"Warehouse\",\n \"address\": {\n \"countryCode\": \"CA\"\n }\n }\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 = <<<QUERY\n mutation createLocationMetafields($input: LocationAddInput!) {\n locationAdd(input: $input) {\n location {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"metafields\" => [{\"namespace\"=>\"my_field\", \"key\"=>\"delivery_type\", \"type\"=>\"single_line_text_field\", \"value\"=>\"local\"}],\n \"name\" => \"Warehouse\",\n \"address\" => [\n \"countryCode\" => \"CA\",\n ],\n ],\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 mutation createLocationMetafields($input: LocationAddInput!) {\n locationAdd(input: $input) {\n location {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"metafields\": [\n {\n \"namespace\": \"my_field\",\n \"key\": \"delivery_type\",\n \"type\": \"single_line_text_field\",\n \"value\": \"local\"\n }\n ],\n \"name\": \"Warehouse\",\n \"address\": {\n \"countryCode\": \"CA\"\n }\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation createLocationMetafields($input: LocationAddInput!) {\n locationAdd(input: $input) {\n location {\n id\n metafields(first: 3) {\n edges {\n node {\n id\n namespace\n key\n value\n }\n }\n }\n }\n userErrors {\n message\n field\n }\n }\n}"
input: { "input": { "metafields": [ { "namespace": "my_field", "key": "delivery_type", "type": "single_line_text_field", "value": "local" } ], "name": "Warehouse", "address": { "countryCode": "CA" } } }
response: { "data": { "locationAdd": { "location": { "id": "gid://shopify/Location/1072404547", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069229305", "namespace": "my_field", "key": "delivery_type", "value": "local" } } ] } }, "userErrors": [] } } }