Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Getting "Internal Error" with GraphQL files API using "reverse" parameter (only for some shops)

Solved

Getting "Internal Error" with GraphQL files API using "reverse" parameter (only for some shops)

DanAtBonify
Shopify Partner
57 4 43
This query fails for one of our app users:
 
 
{
    files(sortKey: CREATED_AT, reverse: true, first: 12, query: "media_type:video OR media_type:image AND -status:FAILED") {
        edges {
            node {
                __typename
                fileStatus
                preview {
                    status
                    image {
                        width
                        height
                        src
                        url(transform: {maxWidth: 300, maxHeight: 300, preferredContentType: PNG})
                    }
                }
                ... on GenericFile {
                    id
                    url
                }
                ... on MediaImage {
                    id
                    image {
                        src
                    }
                }
                ... on Video {
                    id
                    filename
                    sources {
                        fileSize
                        format
                        height
                        width
                        mimeType
                        url
                    }
                }
            }
            cursor
        }
        pageInfo {
            hasNextPage
        }
    }
}
 
 
Internal error. Looks like something went wrong on our end.
Request ID: be66bd1a-06aa-4af9-acb2-472ffb749cd5 (include this in support requests).
 
However, if I change the reverse: true parameter to reverse: false it works.
 
Curiously the reverse: true works if I change the sortKey to FILENAME or ORIGINAL_UPLOAD_SIZE. sortKey of ID still has an error though.
Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 527

This is an accepted solution.

Hi @DanAtBonify 👋

 

Thanks for sharing the request ID! Would you mind checking whether your app has the `read_files` scope using the below query? 

 

{
    currentAppInstallation {
        accessScopes {
            handle
        }
    }
}

 

I've seen similar behaviours with the `reverse` param on interface types since there may be an additional scope required for the returned object. In this case, I suspect it's the `GenericFile` type causing the issue. You should be able to check it with the below, if it throws a similar 500 error:

 

query {
    files (first:3, query: "media_type:generic_file"){
        nodes {
            __typename
        }
    }
}

 

@Umiko

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 238 527

This is an accepted solution.

Hi @DanAtBonify 👋

 

Thanks for sharing the request ID! Would you mind checking whether your app has the `read_files` scope using the below query? 

 

{
    currentAppInstallation {
        accessScopes {
            handle
        }
    }
}

 

I've seen similar behaviours with the `reverse` param on interface types since there may be an additional scope required for the returned object. In this case, I suspect it's the `GenericFile` type causing the issue. You should be able to check it with the below, if it throws a similar 500 error:

 

query {
    files (first:3, query: "media_type:generic_file"){
        nodes {
            __typename
        }
    }
}

 

@Umiko

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

DanAtBonify
Shopify Partner
57 4 43

Thank you!

 

Yes, indeed the read_files scope was missing. It was confusing because apparently some file types don't need that permission, so they load correctly. 

Also made confusing by the error message. I would expect a more specific error message referring to the specific missing scope.

ShopifyDevSup
Shopify Staff
1453 238 527

Absolutely, the error message should be clearer. I'll submit an issue to adjust the error to reference the missing scope instead. Thanks for flagging this!

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog