draft Order Updatemutation
Requires write
access scope. Also: The user must have access to manage draft orders.
Updates a draft order.
If a checkout has been started for a draft order, any update to the draft will unlink the checkout. Checkouts are created but not immediately completed when opening the merchant credit card modal in the admin, and when a buyer opens the invoice URL. This is usually fine, but there is an edge case where a checkout is in progress and the draft is updated before the checkout completes. This will not interfere with the checkout and order creation, but if the link from draft to checkout is broken the draft will remain open even after the order is created.
Arguments
Specifies the draft order to update.
The draft order properties to update.
DraftOrderUpdatePayload returns
The updated draft order.
The list of errors that occurred from executing the mutation.
Code examples for MUTATION: draftOrderUpdate
Query Reference for MUTATION: draftOrderUpdate
"mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n # DraftOrder fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: draftOrderUpdate
"{\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"input\": {\n \"acceptAutomaticDiscounts\": true,\n \"allowDiscountCodesInCheckout\": true,\n \"appliedDiscount\": {\n \"amount\": \"100.57\",\n \"amountWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"description\": \"<your-description>\",\n \"title\": \"<your-title>\",\n \"value\": 1.1,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"<your-address1>\",\n \"address2\": \"<your-address2>\",\n \"city\": \"<your-city>\",\n \"company\": \"<your-company>\",\n \"country\": \"<your-country>\",\n \"countryCode\": \"AC\",\n \"firstName\": \"<your-firstName>\",\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"lastName\": \"<your-lastName>\",\n \"phone\": \"<your-phone>\",\n \"province\": \"<your-province>\",\n \"provinceCode\": \"<your-provinceCode>\",\n \"zip\": \"<your-zip>\"\n },\n \"customAttributes\": [\n {\n \"key\": \"<your-key>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"discountCodes\": [\n \"<your-discountCodes>\"\n ],\n \"email\": \"<your-email>\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"amountWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"description\": \"<your-description>\",\n \"title\": \"<your-title>\",\n \"value\": 1.1,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"bundleComponents\": [\n {\n \"quantity\": 1,\n \"uuid\": \"<your-uuid>\",\n \"variantId\": \"gid://shopify/<objectName>/10079785100\"\n }\n ],\n \"customAttributes\": [\n {\n \"key\": \"<your-key>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"grams\": 1,\n \"originalUnitPrice\": \"100.57\",\n \"originalUnitPriceWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"<your-sku>\",\n \"taxable\": true,\n \"title\": \"<your-title>\",\n \"uuid\": \"<your-uuid>\",\n \"variantId\": \"gid://shopify/<objectName>/10079785100\",\n \"weight\": {\n \"unit\": \"GRAMS\",\n \"value\": 1.1\n }\n }\n ],\n \"localizationExtensions\": [\n {\n \"key\": \"SHIPPING_CREDENTIAL_BR\",\n \"value\": \"<your-value>\"\n }\n ],\n \"marketRegionCountryCode\": \"AC\",\n \"metafields\": [\n {\n \"description\": \"<your-description>\",\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"key\": \"<your-key>\",\n \"namespace\": \"<your-namespace>\",\n \"type\": \"<your-type>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"note\": \"<your-note>\",\n \"paymentTerms\": {\n \"paymentSchedules\": [\n {\n \"dueAt\": \"2019-09-07T15:50:00Z\",\n \"issuedAt\": \"2019-09-07T15:50:00Z\"\n }\n ],\n \"paymentTermsTemplateId\": \"gid://shopify/<objectName>/10079785100\"\n },\n \"phone\": \"<your-phone>\",\n \"poNumber\": \"<your-poNumber>\",\n \"presentmentCurrencyCode\": \"AED\",\n \"purchasingEntity\": {\n \"customerId\": \"gid://shopify/<objectName>/10079785100\",\n \"purchasingCompany\": {\n \"companyContactId\": \"gid://shopify/<objectName>/10079785100\",\n \"companyId\": \"gid://shopify/<objectName>/10079785100\",\n \"companyLocationId\": \"gid://shopify/<objectName>/10079785100\"\n }\n },\n \"reserveInventoryUntil\": \"2019-09-07T15:50:00Z\",\n \"sessionToken\": \"<your-sessionToken>\",\n \"shippingAddress\": {\n \"address1\": \"<your-address1>\",\n \"address2\": \"<your-address2>\",\n \"city\": \"<your-city>\",\n \"company\": \"<your-company>\",\n \"country\": \"<your-country>\",\n \"countryCode\": \"AC\",\n \"firstName\": \"<your-firstName>\",\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"lastName\": \"<your-lastName>\",\n \"phone\": \"<your-phone>\",\n \"province\": \"<your-province>\",\n \"provinceCode\": \"<your-provinceCode>\",\n \"zip\": \"<your-zip>\"\n },\n \"shippingLine\": {\n \"price\": \"100.57\",\n \"priceWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"shippingRateHandle\": \"<your-shippingRateHandle>\",\n \"title\": \"<your-title>\"\n },\n \"sourceName\": \"<your-sourceName>\",\n \"tags\": [\n \"<your-tags>\"\n ],\n \"taxExempt\": true,\n \"transformerFingerprint\": \"<your-transformerFingerprint>\",\n \"useCustomerDefaultAddress\": true,\n \"visibleToCustomer\": true\n }\n}"
Schema Reference for MUTATION: draftOrderUpdate
"input DraftOrderInput {\n acceptAutomaticDiscounts: Boolean\n allowDiscountCodesInCheckout: Boolean\n appliedDiscount: DraftOrderAppliedDiscountInput\n billingAddress: MailingAddressInput\n customAttributes: [AttributeInput!]\n customerId: ID\n discountCodes: [String!]\n email: String\n lineItems: [DraftOrderLineItemInput!]\n localizationExtensions: [LocalizationExtensionInput!]\n marketRegionCountryCode: CountryCode\n metafields: [MetafieldInput!]\n note: String\n paymentTerms: PaymentTermsInput\n phone: String\n poNumber: String\n presentmentCurrencyCode: CurrencyCode\n privateMetafields: [PrivateMetafieldInput!]\n purchasingEntity: PurchasingEntityInput\n reserveInventoryUntil: DateTime\n sessionToken: String\n shippingAddress: MailingAddressInput\n shippingLine: ShippingLineInput\n sourceName: String\n tags: [String!]\n taxExempt: Boolean\n transformerFingerprint: String\n useCustomerDefaultAddress: Boolean\n visibleToCustomer: Boolean\n}\n\ninput DraftOrderAppliedDiscountInput {\n amount: Money\n amountWithCurrency: MoneyInput\n description: String\n title: String\n value: Float!\n valueType: DraftOrderAppliedDiscountType!\n}\n\ninput MailingAddressInput {\n address1: String\n address2: String\n city: String\n company: String\n country: String\n countryCode: CountryCode\n firstName: String\n id: ID\n lastName: String\n phone: String\n province: String\n provinceCode: String\n zip: String\n}\n\ninput AttributeInput {\n key: String!\n value: String!\n}\n\ninput DraftOrderLineItemInput {\n appliedDiscount: DraftOrderAppliedDiscountInput\n bundleComponents: [BundlesDraftOrderBundleLineItemComponentInput!]\n customAttributes: [AttributeInput!]\n grams: Int\n originalUnitPrice: Money\n originalUnitPriceWithCurrency: MoneyInput\n quantity: Int!\n requiresShipping: Boolean\n sku: String\n taxable: Boolean\n title: String\n uuid: String\n variantId: ID\n weight: WeightInput\n}\n\ninput LocalizationExtensionInput {\n key: LocalizationExtensionKey!\n value: String!\n}\n\ninput MetafieldInput {\n description: String\n id: ID\n key: String\n namespace: String\n type: String\n value: String\n}\n\ninput PaymentTermsInput {\n paymentSchedules: [PaymentScheduleInput!]\n paymentTermsTemplateId: ID\n}\n\ninput PrivateMetafieldInput {\n key: String!\n namespace: String!\n owner: ID\n valueInput: PrivateMetafieldValueInput!\n}\n\ninput PurchasingEntityInput {\n customerId: ID\n purchasingCompany: PurchasingCompanyInput\n}\n\ninput ShippingLineInput {\n price: Money\n priceWithCurrency: MoneyInput\n shippingRateHandle: String\n title: String\n}\n"
Display Examples for MUTATION: draftOrderUpdate
[ { "example": { "type_name": "draftorderupdate", "title": "Create a new metafield and update another on an existing draft order", "description": "Create a new metafield `my_field.delivery_instructions` and update an\nexisting metafield `my_fields.purchase_order` on a specific\ndraft order.\n\n\nAlternatively, refer to the\n[metafieldsSet](https://shopify.dev/api/admin-graphql/latest/mutations/metafieldsset) mutation\nto create and/or update metafields on draft order resources.\n", "query_string": "mutation updateDraftOrderMetafields($input: DraftOrderInput!, $ownerId: ID!) {\n draftOrderUpdate(input: $input, id: $ownerId) {\n draftOrder {\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}", "variables": { "input": { "metafields": [ { "namespace": "my_field", "key": "delivery_instructions", "type": "single_line_text_field", "value": "leave on back porch" }, { "id": "gid://shopify/Metafield/1069229013", "value": "123" } ] }, "ownerId": "gid://shopify/DraftOrder/276395349" }, "response": { "data": { "draftOrderUpdate": { "draftOrder": { "id": "gid://shopify/DraftOrder/276395349", "metafields": { "edges": [ { "node": { "id": "gid://shopify/Metafield/1069229013", "namespace": "my_fields", "key": "purchase_order", "value": "123" } }, { "node": { "id": "gid://shopify/Metafield/1069229014", "namespace": "my_field", "key": "delivery_instructions", "value": "leave on back porch" } } ] } }, "userErrors": [] } } }, "api_name": "admin", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_update_test.rb", "minimum_api_version": null, "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\": \"mutation updateDraftOrderMetafields($input: DraftOrderInput!, $ownerId: ID!) { draftOrderUpdate(input: $input, id: $ownerId) { draftOrder { 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_instructions\",\n \"type\": \"single_line_text_field\",\n \"value\": \"leave on back porch\"\n },\n {\n \"id\": \"gid://shopify/Metafield/1069229013\",\n \"value\": \"123\"\n }\n ]\n },\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateDraftOrderMetafields($input: DraftOrderInput!, $ownerId: ID!) {\n draftOrderUpdate(input: $input, id: $ownerId) {\n draftOrder {\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_instructions\",\n \"type\": \"single_line_text_field\",\n \"value\": \"leave on back porch\"\n },\n {\n \"id\": \"gid://shopify/Metafield/1069229013\",\n \"value\": \"123\"\n }\n ]\n },\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\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 mutation updateDraftOrderMetafields($input: DraftOrderInput!, $ownerId: ID!) {\n draftOrderUpdate(input: $input, id: $ownerId) {\n draftOrder {\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_instructions\", \"type\"=>\"single_line_text_field\", \"value\"=>\"leave on back porch\"}, {\"id\"=>\"gid://shopify/Metafield/1069229013\", \"value\"=>\"123\"}]\n },\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\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\": `mutation updateDraftOrderMetafields($input: DraftOrderInput!, $ownerId: ID!) {\n draftOrderUpdate(input: $input, id: $ownerId) {\n draftOrder {\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_instructions\",\n \"type\": \"single_line_text_field\",\n \"value\": \"leave on back porch\"\n },\n {\n \"id\": \"gid://shopify/Metafield/1069229013\",\n \"value\": \"123\"\n }\n ]\n },\n \"ownerId\": \"gid://shopify/DraftOrder/276395349\"\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 mutation updateDraftOrderMetafields($input: DraftOrderInput!, $ownerId: ID!) {\n draftOrderUpdate(input: $input, id: $ownerId) {\n draftOrder {\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_instructions\", \"type\"=>\"single_line_text_field\", \"value\"=>\"leave on back porch\"}, {\"id\"=>\"gid://shopify/Metafield/1069229013\", \"value\"=>\"123\"}],\n ],\n \"ownerId\" => \"gid://shopify/DraftOrder/276395349\",\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The draft order properties to update.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"metafields\":[{\"namespace\":\"my_field\",\"key\":\"delivery_instructions\",\"type\":\"single_line_text_field\",\"value\":\"leave on back porch\"},{\"id\":\"gid://shopify/Metafield/1069229013\",\"value\":\"123\"}]}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "draftorderupdate", "title": "Update the draft order shipping address", "query_string": "mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n shippingAddress {\n id\n }\n }\n }\n}", "variables": { "id": "gid://shopify/DraftOrder/276395349", "input": { "shippingAddress": { "address1": "123 shipping ave", "city": "Ottawa", "provinceCode": "ON", "zip": "K1L 2J3", "country": "Canada" } } }, "response": { "data": { "draftOrderUpdate": { "draftOrder": { "shippingAddress": { "id": "gid://shopify/MailingAddress/639215345?model_name=Address" } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_update_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\": \"mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) { draftOrderUpdate(id: $id, input: $input) { draftOrder { shippingAddress { id } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"shippingAddress\": {\n \"address1\": \"123 shipping ave\",\n \"city\": \"Ottawa\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K1L 2J3\",\n \"country\": \"Canada\"\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n shippingAddress {\n id\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"shippingAddress\": {\n \"address1\": \"123 shipping ave\",\n \"city\": \"Ottawa\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K1L 2J3\",\n \"country\": \"Canada\"\n }\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n shippingAddress {\n id\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"shippingAddress\": {\n \"address1\": \"123 shipping ave\",\n \"city\": \"Ottawa\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K1L 2J3\",\n \"country\": \"Canada\"\n }\n }\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\": `mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n shippingAddress {\n id\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"shippingAddress\": {\n \"address1\": \"123 shipping ave\",\n \"city\": \"Ottawa\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K1L 2J3\",\n \"country\": \"Canada\"\n }\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n shippingAddress {\n id\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DraftOrder/276395349\",\n \"input\" => [\n \"shippingAddress\" => [\n \"address1\" => \"123 shipping ave\",\n \"city\" => \"Ottawa\",\n \"provinceCode\" => \"ON\",\n \"zip\" => \"K1L 2J3\",\n \"country\" => \"Canada\",\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "Specifies the draft order to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DraftOrder/276395349\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The draft order properties to update.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"shippingAddress\":{\"address1\":\"123 shipping ave\",\"city\":\"Ottawa\",\"provinceCode\":\"ON\",\"zip\":\"K1L 2J3\",\"country\":\"Canada\"}}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "draftorderupdate", "title": "Update the draft order to multi-currency with market country", "query_string": "mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n }\n}", "variables": { "id": "gid://shopify/DraftOrder/276395349", "input": { "marketRegionCountryCode": "CA", "presentmentCurrencyCode": "CAD" } }, "response": { "data": { "draftOrderUpdate": { "draftOrder": { "totalPriceSet": { "shopMoney": { "amount": "71.74", "currencyCode": "USD" }, "presentmentMoney": { "amount": "89.68", "currencyCode": "CAD" } }, "marketName": "Primary market", "marketRegionCountryCode": "CA", "presentmentCurrencyCode": "CAD" } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_update_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\": \"mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) { draftOrderUpdate(id: $id, input: $input) { draftOrder { totalPriceSet { shopMoney { amount currencyCode } presentmentMoney { amount currencyCode } } marketName marketRegionCountryCode presentmentCurrencyCode } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\"\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\"\n }\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\": `mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\"\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n presentmentMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DraftOrder/276395349\",\n \"input\" => [\n \"marketRegionCountryCode\" => \"CA\",\n \"presentmentCurrencyCode\" => \"CAD\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "Specifies the draft order to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DraftOrder/276395349\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The draft order properties to update.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"marketRegionCountryCode\":\"CA\",\"presentmentCurrencyCode\":\"CAD\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "draftorderupdate", "title": "Updating a draft order that doesn't exist returns an error", "query_string": "mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n}", "variables": { "id": "gid://shopify/DraftOrder/1", "input": { "note": "This is a really awesome draft order" } }, "response": { "data": { "draftOrderUpdate": { "draftOrder": null, "userErrors": [ { "message": "Draft order not found", "field": null } ] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_update_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\": \"mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) { draftOrderUpdate(id: $id, input: $input) { draftOrder { id } userErrors { message field } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/1\",\n \"input\": {\n \"note\": \"This is a really awesome draft order\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DraftOrder/1\",\n \"input\": {\n \"note\": \"This is a really awesome draft order\"\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DraftOrder/1\",\n \"input\": {\n \"note\": \"This is a really awesome draft order\"\n }\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\": `mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/1\",\n \"input\": {\n \"note\": \"This is a really awesome draft order\"\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n id\n }\n userErrors {\n message\n field\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DraftOrder/1\",\n \"input\" => [\n \"note\" => \"This is a really awesome draft order\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "Specifies the draft order to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DraftOrder/1\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The draft order properties to update.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"note\":\"This is a really awesome draft order\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "draftorderupdate", "title": "Updating a draft order with a company, location and company contact", "query_string": "mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n purchasingEntity {\n ... on PurchasingCompany {\n company {\n id\n }\n }\n }\n }\n }\n}", "variables": { "id": "gid://shopify/DraftOrder/276395349", "input": { "purchasingEntity": { "purchasingCompany": { "companyId": "gid://shopify/Company/426793626", "companyLocationId": "gid://shopify/CompanyLocation/441870438", "companyContactId": "gid://shopify/CompanyContact/207808057" } } } }, "response": { "data": { "draftOrderUpdate": { "draftOrder": { "purchasingEntity": { "company": { "id": "gid://shopify/Company/426793626" } } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_update_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\": \"mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) { draftOrderUpdate(id: $id, input: $input) { draftOrder { purchasingEntity { ... on PurchasingCompany { company { id } } } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n purchasingEntity {\n ... on PurchasingCompany {\n company {\n id\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n }\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n purchasingEntity {\n ... on PurchasingCompany {\n company {\n id\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n }\n }\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\": `mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n purchasingEntity {\n ... on PurchasingCompany {\n company {\n id\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DraftOrder/276395349\",\n \"input\": {\n \"purchasingEntity\": {\n \"purchasingCompany\": {\n \"companyId\": \"gid://shopify/Company/426793626\",\n \"companyLocationId\": \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\": \"gid://shopify/CompanyContact/207808057\"\n }\n }\n }\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 mutation draftOrderUpdate($id: ID!, $input: DraftOrderInput!) {\n draftOrderUpdate(id: $id, input: $input) {\n draftOrder {\n purchasingEntity {\n ... on PurchasingCompany {\n company {\n id\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DraftOrder/276395349\",\n \"input\" => [\n \"purchasingEntity\" => [\n \"purchasingCompany\" => [\n \"companyId\" => \"gid://shopify/Company/426793626\",\n \"companyLocationId\" => \"gid://shopify/CompanyLocation/441870438\",\n \"companyContactId\" => \"gid://shopify/CompanyContact/207808057\",\n ],\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "Specifies the draft order to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DraftOrder/276395349\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The draft order properties to update.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"purchasingEntity\":{\"purchasingCompany\":{\"companyId\":\"gid://shopify/Company/426793626\",\"companyLocationId\":\"gid://shopify/CompanyLocation/441870438\",\"companyContactId\":\"gid://shopify/CompanyContact/207808057\"}}}", "typeKind": "MUTATION" } ] } ]