gift Card Updatemutation
mutation
2024-10latest
Requires write
access scope. Also: User needs gift_cards permission.
Update a gift card.
Arguments
The ID of the gift card to be updated.
The input fields to update the gift card.
Was this section helpful?
GiftCardUpdatePayload returns
The updated gift card.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: giftCardUpdate
Query Reference for MUTATION: giftCardUpdate
"mutation giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n giftCard {\n # GiftCard fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: giftCardUpdate
"{\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"input\": {\n \"customerId\": \"gid://shopify/<objectName>/10079785100\",\n \"expiresOn\": \"2019-07-16\",\n \"note\": \"<your-note>\",\n \"recipientAttributes\": {\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"message\": \"<your-message>\",\n \"preferredName\": \"<your-preferredName>\",\n \"sendNotificationAt\": \"2019-09-07T15:50:00Z\"\n },\n \"templateSuffix\": \"<your-templateSuffix>\"\n }\n}"
Schema Reference for MUTATION: giftCardUpdate
"input GiftCardUpdateInput {\n customerId: ID\n expiresOn: Date\n note: String\n recipientAttributes: GiftCardRecipientInput\n templateSuffix: String\n}\n\ninput GiftCardRecipientInput {\n id: ID!\n message: String\n preferredName: String\n sendNotificationAt: DateTime\n}\n"
Display Examples for MUTATION: giftCardUpdate
[ { "example": { "type_name": "giftcardupdate", "title": "Update a gift card's customer", "query_string": "mutation giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n customer {\n id\n }\n }\n }\n}", "query_arguments": { "id": "$id", "input": "$input" }, "variables": { "id": "gid://shopify/GiftCard/63396415", "input": { "customerId": "gid://shopify/Customer/331283560" } }, "response": { "data": { "giftCardUpdate": { "userErrors": [], "giftCard": { "id": "gid://shopify/GiftCard/63396415", "customer": { "id": "gid://shopify/Customer/331283560" } } } } }, "api_name": "admin", "location": "/components/stored_value_instruments/gift_cards/test/unit/graph_api/admin/mutations/gift_card_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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) { giftCardUpdate(id: $id, input: $input) { userErrors { message field } giftCard { id customer { id } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/GiftCard/63396415\",\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/331283560\"\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n customer {\n id\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/GiftCard/63396415\",\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/331283560\"\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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n customer {\n id\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/GiftCard/63396415\",\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/331283560\"\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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n customer {\n id\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/GiftCard/63396415\",\n \"input\": {\n \"customerId\": \"gid://shopify/Customer/331283560\"\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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n customer {\n id\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/GiftCard/63396415\",\n \"input\" => [\n \"customerId\" => \"gid://shopify/Customer/331283560\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the gift card to be updated.", "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/GiftCard/63396415\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The input fields to update the gift card.", "type": { "kind": "INPUT_OBJECT", "name": "GiftCardUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "GiftCardUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"customerId\":\"gid://shopify/Customer/331283560\"}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "giftcardupdate", "title": "Updating a gift card's expiration date so that it will never expire", "query_string": "mutation giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n }\n }\n}", "query_arguments": { "id": "$id", "input": "$input" }, "variables": { "id": "gid://shopify/GiftCard/746346263", "input": { "expiresOn": null } }, "response": { "data": { "giftCardUpdate": { "userErrors": [], "giftCard": { "id": "gid://shopify/GiftCard/746346263", "expiresOn": null } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/stored_value_instruments/gift_cards/test/unit/graph_api/admin/mutations/gift_card_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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) { giftCardUpdate(id: $id, input: $input) { userErrors { message field } giftCard { id expiresOn } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/GiftCard/746346263\",\n \"input\": {\n \"expiresOn\": null\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/GiftCard/746346263\",\n \"input\": {\n \"expiresOn\": null\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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/GiftCard/746346263\",\n \"input\": {\n \"expiresOn\": null\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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/GiftCard/746346263\",\n \"input\": {\n \"expiresOn\": null\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 giftCardUpdate($id: ID!, $input: GiftCardUpdateInput!) {\n giftCardUpdate(id: $id, input: $input) {\n userErrors {\n message\n field\n }\n giftCard {\n id\n expiresOn\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/GiftCard/746346263\",\n \"input\" => [\n \"expiresOn\" => null,\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the gift card to be updated.", "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/GiftCard/746346263\"", "typeKind": "MUTATION" }, { "arg": { "name": "input", "description": "The input fields to update the gift card.", "type": { "kind": "INPUT_OBJECT", "name": "GiftCardUpdateInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "GiftCardUpdateInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"expiresOn\":null}", "typeKind": "MUTATION" } ] } ]