I have the Apollo client configured as per the docs, using the ApolloProvider
so that I may be able to use useQuery
in nested components. When I run queries using the apolloClient
that is provided to the ApolloProvider
, I.e.:
apolloClient.query({query, variables});
queries work just fine. However, in a screen further down the tree I have something like the following:
export default function SomeScreen({ route }: RouteProps) { ... let query: DocumentNode; switch (route.params.someParam) { case 'A': query = someQuery1; break; ... default: query = someQueryX; } const {loading, error, data} = useQuery<{myData: SomeType[]}, QueryArgTypes>( query, {variables}, //assigned elsewhere but they're constant ); if (loading) return <Text>Loading</Text> if (error) return <Text>Error</Text> return (<FlatList data={data?.myData} renderItem={({ item }) => (<SomeComp elem={item} />)} keyExtractor={(item) => ( item._id!.toString() )} /> );}
However, in this case, the if (loading)
branch is just always true. Furthermore, the uri
I used when instantiating apolloClient
is one which is part of the project I'm working on. I was able to set break points in it to pause execution when my query
executes, and it never reaches any of the breakpoints I've set at all. So as far as I can tell, useQuery
isn't even trying to execute the query (never makes it to the backend) but I don't get any description of what's going on. Anyone have any idea what might be happening? Some relevant dependencies are:
"react": "17.0.1","react-native": "0.64.3","@apollo/client": "^3.6.2",