Tag: #reactjs
-
Gatsby ,GraphQl content mapping bug
0 I am using Gatsby, GraphQl, and contentful. In my project i am trying to connect specific banner section to specific page (like home page should have banner of home and similarly for about us page and other pages) and i am writing my code for banner in banner.jsx . so the approach is every…
-
Expected 1-2 arguments, but got 3. react tanstack query options
0 Using graphql codegen.yml file: `# 1. Schema (graphql schema location) schema: "src/graphql/schema.graphql" documents: "src/graphql/*.graphql" generates: src/graphql/generated.ts: plugins: – typescript – typescript-operations – typescript-react-query – fragment-matcher config: dedupeFragments: true fetcher: # Function to run func: "./auth-fetcher#fetchData" isReactHook: false` My auth-fetcher file using react query fetcher from https://the-guild.dev/graphql/codegen/plugins/typescript/typescript-react-query `export const fetchData = <TData, TVariables>( query: string,…
-
Why I got error: Cannot query field xx on type “Query”?
57 Although I copied and pasted the graphQL query from the GraphiQL tool after I tested it at GraphiQL successfully , the query returned with an error when I tried it in Apollo client within a reactJS app: [GraphQL error]: Message: Cannot query field “allStudents” on type “Query”., Location: [object Object], Path: undefined Here is…
-
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…
-
How to use Apollo’s multiple useQuery() hooks in React
2 I need to use 2 queries in my file and I am writing them like so: const {loading, data } = useQuery(getCharactersQuery); const {loading, data} = useQuery(getSingleCharacterQuery); The problem is, they both have the same "loading" and "data" variables and I don’t see anywhere in the docs how can we have different ones. How…
-
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 fix GraphQL error – Not Authorized
2 I keep geting this error: Error: GraphQL error: Not Authorized! Code is: const queries = gql` query { mystreak } `; render() { return ( <Query query={queries}> {({ loading, error, data }) => { console.log(loading); console.log(error); console.log(data.mystreak); }} </Query> ) } App is built in React.js, and I am pretty new to GraphQL. Also…
-
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 query header with variable not setting on first render
0 I am using graphQL in react native project. I am passing headers (cookie/authorization) in context object of query, in useMutation or useQuery. [Problem is only on iOS App] The basic system of the app is user signup the profile, and verify, on initial signup the property finishedAccountSetup: false is false. so when they log…