Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hi, we're trying to update a metaobject including ratings for our store via the GraphQL API. We're using the shopify-api-node by monei to do this. Receiving data such as the metaobject's id was successful, but we can't seem to update the metaobject's data.
This is our code:
const query = `mutation metaobjectUpdate($id: ID!, $metaobject: MetaobjectUpdateInput!) { metaobjectUpdate(id: $id, metaobject: $metaobject) { metaobject { rating count } userErrors { field message code } } }`; const variables = `{ "id": "gid://shopify/Metaobject/2085388555", "metaobject": { "fields": [ { "key": "rating", "value": 4.1 }, { "key": "count", "value": 700 } ] } }`; const test = `{ metaobjects(type: "reviews", first: 3) { edges { node { id handle } } } }`; return await shopify.graphql(query, variables);
And this is the response:
HTTPError: Response code 400 (Bad Request) at Request.<anonymous> (/Users/<hidden-stuff>/node_modules/got/dist/source/as-promise/index.js:118:42) at processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 'ERR_NON_2XX_3XX_RESPONSE', timings: { start: 1687252703717, socket: 1687252703718, lookup: 1687252703721, connect: 1687252703750, secureConnect: 1687252703788, upload: 1687252703788, response: 1687252703891, end: 1687252703891, error: undefined, abort: undefined, phases: { wait: 1, dns: 3, tcp: 29, tls: 38, request: 0, firstByte: 103, download: 0, total: 174 } } }
As you can see it's pretty useless. Does anyone see what we're doing wrong?