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 { draftOrder(id: \\\"gid://shopify/DraftOrder/276395349\\\") { name } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\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 draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\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 draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n}"
input: null
response: { "data": { "draftOrder": { "name": "#D1" } } }
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 { draftOrder1: draftOrder(id: \\\"gid://shopify/DraftOrder/276395349\\\") { name } draftOrder2: draftOrder(id: \\\"gid://shopify/DraftOrder/221448317\\\") { name } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\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 draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\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 draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n draftOrder1: draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n name\n }\n draftOrder2: draftOrder(id: \"gid://shopify/DraftOrder/221448317\") {\n name\n }\n}"
input: null
response: { "data": { "draftOrder1": { "name": "#D1" }, "draftOrder2": { "name": "#D7" } } }
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 { draftOrder(id: \\\"gid://shopify/DraftOrder/276395349\\\") { lineItems(first: 5) { edges { node { name } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\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 query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\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([\"query\" => $query]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n draftOrder(id: \"gid://shopify/DraftOrder/276395349\") {\n lineItems(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n }\n}"
input: null
response: { "data": { "draftOrder": { "lineItems": { "edges": [ { "node": { "name": "Boots - Default" } } ] } } } }
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 DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) { draftOrder(id: $ownerId) { purchaseOrder: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\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 DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\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\" => \"purchase_order\",\n \"ownerId\" => \"gid://shopify/DraftOrder/276395349\",\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 DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"purchase_order\",\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DraftOrderMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n draftOrder(id: $ownerId) {\n purchaseOrder: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}"
input: { "namespace": "my_fields", "key": "purchase_order", "ownerId": "gid://shopify/DraftOrder/276395349" }
response: { "data": { "draftOrder": { "purchaseOrder": { "value": "123" } } } }
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 DraftOrderMetafields($ownerId: ID!) { draftOrder(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DraftOrderMetafields($ownerId: ID!) {\n draftOrder(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/DraftOrder/276395349\"\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 DraftOrderMetafields($ownerId: ID!) {\n draftOrder(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/DraftOrder/276395349\"\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/DraftOrder/276395349\",\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 DraftOrderMetafields($ownerId: ID!) {\n draftOrder(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/DraftOrder/276395349\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DraftOrderMetafields($ownerId: ID!) {\n draftOrder(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/DraftOrder/276395349" }
response: { "data": { "draftOrder": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "purchase_order", "value": "123" } } ] } } } }