I used the interface in the following document to test the product’s operations creation function, but why do I always make mistakes. I am using case code. document url:https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productOptionsCreate?language=cURL errors: stdClass Object ( [errors] => Array ( [0] => stdClass Object ( [message] => OptionCreateInput isn’t a defined input type (on $options) [locations] => Array ( [0] => stdClass Object ( [line] => 1 [column] => 41 ) ) [path] => Array ( [0] => mutation createOptions ) [extensions] => stdClass Object ( [code] => variableRequiresValidType [typeName] => OptionCreateInput [variableName] => options ) ) [1] => stdClass Object ( [message] => Field ‘productOptionsCreate’ doesn’t exist on type ‘Mutation’ [locations] => Array ( [0] => stdClass Object ( [line] => 1 [column] => 76 ) ) [path] => Array ( [0] => mutation createOptions [1] => productOptionsCreate ) [extensions] => stdClass Object ( [code] => undefinedField [typeName] => Mutation [fieldName] => productOptionsCreate ) ) [2] => stdClass Object ( [message] => Variable $productId is declared by createOptions but not used [locations] => Array ( [0] => stdClass Object ( [line] => 1 [column] => 1 ) ) [path] => Array ( [0] => mutation createOptions ) [extensions] => stdClass Object ( [code] => variableNotUsed [variableName] => productId ) ) [3] => stdClass Object ( [message] => Variable $options is declared by createOptions but not used [locations] => Array ( [0] => stdClass Object ( [line] => 1 [column] => 1 ) ) [path] => Array ( [0] => mutation createOptions ) [extensions] => stdClass Object ( [code] => variableNotUsed [variableName] => options ) ) ) ) postdata: { “query”: “mutation createOptions($productId: ID!, $options: [OptionCreateInput!]!) { productOptionsCreate(productId: $productId, options: $options) { userErrors { field message code } product { id variants(first: 5) { nodes { id title selectedOptions { name value } } } options { id name values position optionValues { id name hasVariants } } } } }”, “variables”: { “productId”: “gid://shopify/Product/7898713718984”, “options”: [ { “name”: “Color”, “values”: [ { “name”: “Blue” }, { “name”: “Red” } ] }, { “name”: “Size”, “values”: [ { “name”: “Small” }, { “name”: “Medium” } ] } ] } }
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| API GraphQL ProductCreate with options error | 2 | 87 | February 27, 2025 | |
| productOptionsCreate mutation creates only 1 option value | 7 | 74 | May 8, 2025 | |
| Create checkout mutation has error | 1 | 11 | November 2, 2023 | |
| productCreate Options API Mutation Not working | 9 | 84 | September 19, 2023 | |
| GraphQL productCreate mutation returns "Expected value to not be null" | 1 | 45 | November 19, 2024 |