Read files from the backend

I am trying to read the files that I have uploaded in shopify backend with the help of this code and library:

const shopify = new Shopify({
  shopName: process.env.STORE_NAME,
  apiKey: process.env.API_KEY,
  password: process.env.STORE_PASSWORD,
});
const query = `{
  files {
    edges {
      node {
        alt
      }
    }
  }
}`;
shopify
  .graphql(query)
  .then((files) => console.log(files))
  .catch((err) => console.error(err));

But I am running into this error:

Error: Field ‘files’ doesn’t exist on type ‘QueryRoot’

Please if anyone can help me I will really appreciate it. Thank you!

1 Like