Questions tagged [react-apollo-hooks]

89 questions
1
vote
2 answers

How to get useLazyQuery hooks data after calling a function

I'm trying to to call useLazyQuery after submitting form/onClick, but for some reason I'm always getting undefined. Here is how I have defined my hook; const component = () => { const [getMyValues, {loading, error, data: myValues}] =…
1
vote
2 answers

Typescript error got undefined with useState hook

Im new to graphql so I decided to follow this guide. However I got an error when querying (step 7) : Argument of type '({ __typename?: "User"; } & Pick)[]' is not assignable to parameter of type…
1
vote
0 answers

How to use initial data with useQuery

I am using useQuery hook in React native android application to fetch the data. When my app starts I get initial rows as a prop from the native side to React native. Then React native layer gets the next page by using the useQuery. As of now, I am…
Pavan Tiwari
  • 3,077
  • 3
  • 31
  • 71
1
vote
1 answer

NextJS Apollo "queryData.ssrInitiated is not a function" error on routing

I have a page items/[id] for creating and editing items. I use -1 as item id for new items to differentiate create and edit mode. It is a functional component and looks like below const getItem = (id) => { if (id > 0) { return…
1
vote
1 answer

Apollo client skip query based on state

Using Apollo Client I see how I can skip a query based on props like shown here https://ladwhocodes.com/graphql/skip-a-graphql-query-based-on-conditions/31/ But what if I want to skip calling my query based on a change in state. I have a query set…
1
vote
1 answer

Using React Navigation with Apollo's useQuery

I have a screen where I fetch some data from Hasura. I am using something like this: // screen1.js const {data} = useQuery(MY_QUERY) In screen1.js I have a button that navigates to screen2.js. And in screen2.js I have some mutation that changes the…
davidaap
  • 1,569
  • 1
  • 18
  • 43
1
vote
0 answers

How do I test Enzyme and apollo graphql hooks?

I have a Modal component that uses a reusable component using useQuery and useMutation: const CCPAModal = ({ addNotification, closeModal }: Props): Node => { const { data, loading: memberInfoLoading } = useQuery(getMemberInfo, {…
nyphur
  • 2,404
  • 2
  • 24
  • 48
1
vote
1 answer

Using @apollo/react-hooks, the react app crashes hard on refresh being expired

When I am not logged in I receiving this error: Unhandled Rejection (Error): GraphQL error: Refresh has expired And it occurrs in this code block: const { loading, error, data } = useQuery(GET_BILLABLE_EVENTS, { fetchPolicy: 'no-cache', …
RobKohr
  • 6,611
  • 7
  • 48
  • 69
1
vote
1 answer

How can I use Apollo React hooks with Storybook?

I'm working on a React project that uses Storybook to mock components. We recently introduced Apollo react hooks (i.e. useQuery) to fetch data for some components. Example: const Component = () => { const { loading, error, data } =…
ACPrice
  • 667
  • 2
  • 10
  • 25
1
vote
0 answers

When I connect more clients on Apollo React only the last client receive GraphQL Subscriptions updates

Basically, when there is more than one client connected, only the last client connected receives GraphQL subscriptions data through the web socket. This doesn't happen with old React classes, it happens only when I use stateless functions through…
Berenluth
  • 509
  • 3
  • 13
1
vote
0 answers

Hook analog for ApolloError class

I am refactoring a old component written on React & Apollo client and I have the next pice of code: export const getBusiness = (query: DocumentNode) => compose([ graphql |…
1
vote
1 answer

How to use the Apollo client directly in a React child component

I have a Toolbar component rendered by an App component, I want to do some api-call update when a toolbar button is clicked eg. 'save'. index.js: ReactDOM.render(
A_L
  • 1,116
  • 2
  • 11
  • 25
1
vote
1 answer

GraphQL query structure

I'm learning GraphQL and am working with Apollo (client and server) I still have some confusion with the structure of GraphQL queries. Questions: Is it possible to merge the lines labeled #1 and #2 together? As the lines are so similar it almost…
Miroslav Glamuzina
  • 4,472
  • 2
  • 19
  • 33
1
vote
1 answer

Is there a way to disable apollo-link-dedup when using apollo useQuery?

Overview I have a component that renders two child components. The child components uses apollo's useQuery to issue a request to the server. The issue is because apollo-link-dedup is included when using apollo-client, only one request is being sent…
1
vote
2 answers

Why is my query called over and over using useLazyQuery? Apollo Hooks

I am using the useLazyQuery hook from Apollo and get in an infinite loop. Here is my component: import styled from 'styled-components' import { useLazyQuery } from "@apollo/react-hooks" import GENERATE_EFT_REFERENCE_NUMBER from…
jhamm
  • 24,124
  • 39
  • 105
  • 179