Metafields not connect with shopify remix app

Solved

Metafields not connect with shopify remix app

CwsSanket
Shopify Partner
8 2 2

"Hello everyone,

I'm currently working on a Remix app and I'm trying to connect with meta-fields using the documentation provided here: [link to documentation]. However, when making the API request, I'm getting a response with {size: 0}. I've double-checked my code and followed the documentation, but I'm still facing this issue. Could anyone help me understand why I might be getting this response and how to resolve it? Any assistance would be greatly appreciated.

Thank you!"

Accepted Solution (1)
ndt_ts
Shopify Partner
25 2 7

This is an accepted solution.

in your case

let response = await metaFieldAdd(admin);
let jsonResponse = await response.json();

now jsonResponse will contain the actual json response for your graphQL query

View solution in original post

Replies 3 (3)

ndt_ts
Shopify Partner
25 2 7

you have to call .json to the response received.

eg:
let res = await graphQLCall();
let actualResponse = res.json();

Now it will give the JSON response of the call..

CwsSanket
Shopify Partner
8 2 2
I already do but i got this response:- { size: 0 }
export async function metaFieldAdd(admin){
  const response = admin.graphql(
    `#graphql
    mutation {
      productUpdate(
      input : {
        id: "gid://shopify/Product/8777886925105",
        metafields: [
          {
            namespace: "instructions",
            key: "wash",
            value: "cold wash",
            type: "single_line_text_field",
          }
        ]
      }) {
        product {
          metafields(first: 100) {
            edges {
              node {
                namespace
                key
                value
              }
            }
          }
        }
      }
    }
    `
  )
  return await response;
}
ndt_ts
Shopify Partner
25 2 7

This is an accepted solution.

in your case

let response = await metaFieldAdd(admin);
let jsonResponse = await response.json();

now jsonResponse will contain the actual json response for your graphQL query