Metafields not connect with shopify remix app

"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!"

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..

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;
}

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

1 Like