Internal error: products filters

Internal error: products filters

BramK
Tourist
5 0 2

Hi all,

 

Been using the "collectionByHandle" graphql request to fetch products for the store of a client for quite a whole without problems. A couple weeks ago I added filters to this request, a bit like so:

 

 

 

 

 

products(
        first: $amount
        sortKey: $sortKey
        reverse: $reverseKey
        after: $afterCursor
        filters: { price: { min: $minPrice, max: $maxPrice } }
      )

 

 

 

 

This worked fine for quite a while, when making the request I pass on the values for minPrice and maxPrice, based on what the customer selected. This was online/live for about 1-2 weeks without any issues.

 

A couple days ago I added a filtering for product tags with the "productMetafield". This also seemed to work fine, until I put it online on my clients website. The website worked for let's say an hour (not sure how long exact), and then crashed with a 500 error. When I spinned up localhost, I got an internal error from Shopify. I figured I did something wrong, removed the "productMetafield" filter. Everything worked again. I ran a new build for the clients website, and we were back live.

 

But again, after a short while, the website crashed, 500. I spin up localhost, to spot again an internal error from Shopify. Really strange, because right now I had the price filters configuration I've had online for weeks, and now it did not work anymore. 

 

If I change the variables of "$minPrice" and "$maxPrice" by actual values in graphQL, it seems to work again. If I keep the variables, but hardcode them to number values while doing the request, the query fails with;

 

Internal error. Looks like something went wrong on our end. Request ID: 9ea1d083-e028-47a3-ad22-50f7b2f01cc4 (include this in support requests).

 

I have no clue how code that worked for 1-2 weeks, all of the sudden causes an internal error. I hope someone can help me shine some light on this. Thanks!

Replies 4 (4)

made4Uo
Shopify Partner
3851 717 1196

Hi @BramK,

 

The only thing I can think of is the request header. You might not have the right header

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free
BramK
Tourist
5 0 2

Hi @made4Uo ,

 

Thanks for the quick reply! This made me take a look at the webhook version inside Shopify, and it was a mismatch with the one I was using. Weird thought that even though that was a mismatch, the filtering did work for a while.

 

I've updated them to match now, version 2022-07. Will update this topic once site is live and running for several hours without issues. Thanks!

BramK
Tourist
5 0 2

Unfortunately, this was not the solution. It's very confusing. I had the product filters running on my localhost again, no problems. Clean cache, no issues. I put the website live, initially shows just fine, couple minutes later; crash. Internal server error. After that, the code gives an error locally as well, while the exact same code worked fine while testing before putting live. It's almost like the API blocks the requests after going live.

 

Headers:

import { GraphQLClient } from "graphql-request";

const endpoint = "https://myclient.myshopify.com/api/2022-07/graphql";

export const graphQLClient = new GraphQLClient(endpoint, {
  headers: {
    "X-Shopify-Storefront-Access-Token": "myaccesstoken",
    Accept: "application/json",
  },
});

 

Don't think anything is wrong there...

made4Uo
Shopify Partner
3851 717 1196

Hi @BramK,

 

It might be because of the updates. I would recommend to contact Shopify support on this. 

If this fixed your issue Likes and Accept as Solution is highly appreciated. Coffee tips fuels my dedication.
Get EXPERIENCED Shopify developers at affordable rates—visit Made4Uo.com for quick quote!
Do not lost your Shopify store! Get FREE trial with ✔️ Rewind Backup: Automatic, reliable, stress-free