I have this in my complicated app: Basically, I have an export button which will export a CSV of my GraphQL data. I manually call client.query to fetch the latest data on click of the button, but it throws an error saying it can’t find the used fragment StuffTable. How do I include that fragment in the query? I am
Tag: apollo
Apollo fetchMore updates data globally
I have two TaskList components that use the same query GET_TASKS. Both use a different filter query variable which is passed down to them in props as queryVars. I defined a standard merge function in type policies to merge the incoming and existing data together. The TaskList component uses to retrieve the data. A Fetch more button has () =>
Apollo Client useQuery making un-necessary refetches upon Next.js router.push
I’m dealing with an issue in which a query inside a useQuery Apollo Client hook is getting un-necessarily re-run whenever Next.js’s router.push (docs here) is called. The abbreviated code is: You can see a reproduction on CodeSandbox here. My expectation is that whenever the button is clicked (and thus router.push is called), the query shouldn’t be re-run. However, it’s re-run
Return multiple queries using Apollo
I am using nextJS for my frontend with apollo and a graphql. And I fetching my queries using the getStaticProps() function. To increase modularity and maintainability I break my queries into multiple queries. I have a folder structure like: src/queries getPost.js getMenu.js getProduct.js index.js And their all queries are put and exported into index.js. The problem is because of multiple
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,
PrivateRouting when Token in Local Storage [TypeScript]
If my login in successful, an authentication token is returned, which is stored in the local storage. Upon successful login, I want to go the a private route. I found this code Javascript snippet but I am unable to make it work for Typescript. I don’t have any isAuthenthicated property yet. How could I modify this accordingly? Here is my