NextJs - Refetch Apollo query on an event

Viewed 75

I have an Apollo Client which is called under the getServerSideProps

export const getServerSideProps: GetServerSideProps = async (context) => {
  const { data } = await searchApolloClient.query({
    query: LIST_QUERY,
    variables: {
      language: 'en',
    },
  });

  return {
    props: {
      listProps: data,
    },
  };
};

Now when I change a dropdown option I want to pass it's id as a variable to this query and refetch the new results without refreshing the page. In Apollo's documentation I found the useLazyQuery which works fine on the client side.

I want to know if there is a way to refetch the data with new variables on the server-side itself.

0 Answers
Related