I'm new to graphql and having a issues on calling multiple graphql queries at once.
For example I have a query and it has to be called 3 times using different variables as I need all the data returned on page initial load.
For that I'm doing something like this
const { data: inventoryActivityResult, loading: inventoryActivityLoading, refetch: inventoryActivityFetch } = useQuery<{
simulcastMyAccount: { data: any };
}>(RETRIEVE_BUYERACTIVITY, {
variables: {
apiKey: apiKey,
list: 'Inventory',
},
});
const { data: offersActivityResult, loading: offersActivityLoading, refetch: offersActivityFetch } = useQuery<{
simulcastMyAccount: { data: any };
}>(RETRIEVE_BUYERACTIVITY, {
variables: {
apiKey: apiKey,
list: 'Offers',
},
});
const { data: bidsActivityResult, loading: bidsActivityLoading, refetch: bidsActivityFetch } = useQuery<{
simulcastMyAccount: { data: any };
}>(RETRIEVE_BUYERACTIVITY, {
variables: {
apiKey: apiKey,
list: 'Bids',
},
});
I was wondering if there's a better way to do this. Is there a simple way to call all this queries without having to repeat the same code?