Skip to content
Advertisement

Tag: graphql

How do I eliminate all these if-else

I have written this code to filter a “books” array, depending on the author or genre have been given as a parameter:- I believe there must be some way to write this more “professionally” without using all these if-else. So if anyone knows a better way, I’ll appreciate it. [Edited] Thanks to all, I decided to go with ghostkraviz solution,

Nested Query GraphQl

I am new using graphql and I would like to know how could I filter my query to get the recipes that has some of the ingredient objects I have in my input array. this is the schema.gql file this recipe schema has 1 respective service and the respective Query resolvers the main idea here is just to have one

Access Javascript Object Value with Dynamic Key

How do you handle accessing the objects inside a JSON response when the key is dynamic? In my code sample, I’ve created a reducer that makes API calls but requires params to work: That function works and it returns a response that gets deposited on fetch that looks like this: In my example response, allLocationss is the key, but some

How can I handle long Int with GraphQL?

As you know that GraphQL has no data type like long int. So, whenever the number is something big like 10000000000, it throws an error like this: Int cannot represent non 32-bit signed integer value: 1000000000000 For that I know two solutions: Use scalars. Use apollo-type-bigint package. Both of those solutions convert the big int to string, and I’d rather

Graphql error: “using last without before is not supported”

I am using Gatsby + GraphQL + Shopify. I am having an issue retrieving my orders by the last 10. My query looks like this: And it returns this: “message”: “using last without before is not supported” I noticed this issue happening to some other devs: https://community.shopify.com/c/Shopify-Discussion/How-to-get-customer-s-orders-and-sort-by-date-in-descending/m-p/629133/highlight/false#M151241 If you check the docs it says nothing about using before with last:

How to run useQuery inside forEach?

I have loop – forEach – which find productId for every element of array. I want to fetch my database by productId using apollo query. How to do it? Answer From the rules of hooks: Don’t call Hooks inside loops, conditions, or nested functions. Instead, always use Hooks at the top level of your React function. By following this rule,

VSCODE Javascript template string become white and lost highlight in a non deterministic way

I don’t know exactly how to express it in words to find related problems. In some cases, apparently random, when using JavaScript string templates, the text editor loses becomes white, with bold text and makes editing the code very difficult. First appearance of the problem was when I started working with javascript string for GraphQL query, then it started showing

Advertisement