Tag: apollo-client
-
onCompleted of Apollo’s useLazyQuery does not get called when the execute function resolves
0 I am facing a problem with the following snippet: const [execute] = useLazyQuery(gql` query Example($id: String!) { node(id: $id) { … on Train { id passengers(first: 1) { totalCount } } } } `) useEffect(() => { execute({ onCompleted: () => console.log("Hello world") }) }, []) interface Node { id: ID! } type PassengerConnection…
-
Laravel Lighthouse / Apollo Client React not sending auth cookies
0 I’m creating a Laravel / React SPA Application using Sanctum Stateful Auth. I’n my local enviroment it works just fine. Cookies are being sent and everything is ok, but when I pass the app to production ( I’m using a shared hosting ). The stateful auth breaks and doesn’t work. It allows me to…
-
GraphQL query is not returning the data at the first fetch itself
0 In my NextJS application, I’m using Apollo Client to query the data. This is the code, //Redeem earnable item const claimableItemId = "5ab7c5ab-7a3d-4a92-a62f-2fbd995955f6"; const destAddr = "0x387961b46242A42B445D4354d5048329410613a7"; const [redeemEarnableItem, { data: redeemItem }] = useMutation( REDEEM_EARNABLE_ITEM, { variables: { claimableItemId, destAddr, }, } ); const { loading, error, data: invoiceDetails, } = useQuery(GET_INVOICE_DETAILS, {…
-
Why state not updating from useMutation?
0 I’m trying to update state(useState) from useMutation(Apollo Client) callbacks, but it is not updating the state. Setting it inside "error" callback. Getting error in console: Warning: Can’t perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions…
-
How to set timeout to graphql-client
7 I’m trying to set timeout with prisma-labs/graphql-request. I’ve tried the way described here – https://github.com/prisma-labs/graphql-request/issues/103. const client = new GraphQLClient(config.url, { timeout: 30000, headers: { Authorization: `Bearer ${token}` } }) My compiler complains as timeout is not directly present in Options interface – https://github.com/prisma-labs/graphql-request/blob/master/src/types.ts#L7. Should I need to extend the Options interface to use…
-
GraphQL codegen using GraphQLError type without importing it
0 This is my codegen config: ‘generated/graphql-sdk.ts’: { config: { rawRequest: true }, plugins: [ "typescript", "typescript-graphql-request", "typescript-operations", { ‘fragment-matcher’: { apolloClientVersion: 3, module: "es2015", useExplicitTyping: false } } ] }, For some reason the generated graphql-sdk doesn’t import GraphQLError causing the typing error, I end up needing to add it in manually. This only…
-
Unnecessary reload needed to load new user data on login with apollo and graphql
0 so I had this problem for a while now and its driving me crazy. There was one answer on here however it did not help at all. So I am here to post my code to see if someone would be able to discern my stupidity. Login component: import React, { useState, useCallback, useEffect…
-
Graphql “Unknown argument “bookId” on field “book” of type “Explore”.”
0 I’m trying to call my API but it keeps giving me 400 Error request with the error of: message: "Unknown argument "bookId" on field "book" of type "Explore"." I’ve just read the documentation of Apollo graphql and tried to fetch my data the way it said with variables and args, and it’s in my…
-
Uncaught (in promise) GraphQLError: Syntax Error: Unexpected character: “.” using GraphQl in Vue
-1 I’m using graphql in Vue and I came up with this problem! This is my code for calling graphql in store: async fetchBookContent({ commit }, data) { let token = data.token let bookId = data.bookId const ALL_BOOKS_QUERIES = gql` query { book(args:{token:${token},bookId:${bookId}}){ information{ name } } } ` const { result } = useQuery(ALL_BOOKS_QUERIES)…
-
testing react form using GraphQl & apollo client at Storybook
0 I have a React Form Component using Graphql & Apollo. I am trying to test this Form at Storybook but I got the following error message : Error: Cannot destructure property ‘MockedProvider’ of ‘context.parameters[PARAM_KEY]’ as it is undefined. here is my Preveiw.ts file content: import type { Preview } from "@storybook/react"; import { MockedProvider…