GraphqlQueryError: Field 'originalFileSize' doesn't exist on type 'MediaImage'

I’m currently using the files API (https://shopify.dev/docs/api/admin-graphql/2024-01/queries/files) to query image information. It works well, but when I follow the demo and add originalFileSize, it prompts: GraphqlQueryError: Field 'originalFileSize' doesn't exist on type 'MediaImage'. I really need this field, so I’ve been trying to resolve this issue but without success. The demo in the documentation shows how to query this field, but I haven’t been successful. Could it be a problem with my code, or is there an issue with the demo code in the documentation?

My api_version is “2024-01”, and my code is as follows:

const response = await admin.graphql(
    `#graphql
    query {
      files(${pageSize}, query:"${condition}" ${pageCondition} reverse:true) {
        edges {
          node {
            createdAt
            updatedAt
            alt
            ... on MediaImage {
              id
              originalFileSize
              image {
                originalSrc: url
                width
                height
              }
            }
          }
        }
        pageInfo {
          hasNextPage
          endCursor
          hasPreviousPage
          startCursor
        }
      }
    }`
  );

Hey @huangcong12 ,

Thanks for sharing your query. Just looking at our documentation here for the MediaImage object, the originalFileSize does not exist there.

There is however the originalSource field that includes the fileSize and url values. https://shopify.dev/docs/api/admin-graphql/2024-01/objects/MediaImage#field-mediaimage-originalsource

It should be this in the example:

{> files(query: “media_type:IMAGE”, first: 3) {> edges {> node {> … on MediaImage {> id> originalSource {> fileSize> url> }> image {> id> originalSrc: url> width> height> }> }> }> }> }> }

I’ll let our docs team know about this!

Hope that helps,

Kyle G.