nextjs-在事件中取代阿波罗查询

发布于 2025-02-08 05:01:10 字数 693 浏览 1 评论 0原文

我有一个Apollo客户端,该客户端在getserversideprops下被调用,

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

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

现在我更改下拉选项时,我想将其ID作为此查询的变量传递给它,并在不刷新页面的情况下删除新结果。在阿波罗的文档中,我找到了 uselazyquery uselazyquery 在客户端可以正常工作。

我想知道是否有一种方法可以在服务器端本身上用新变量来灌输数据。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文