{"id":384662,"date":"2023-05-31T13:01:13","date_gmt":"2023-05-31T13:01:13","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=384662"},"modified":"2024-06-25T07:11:33","modified_gmt":"2024-06-25T07:11:33","slug":"use-of-fetchmore-usequery-in-nextjs","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/","title":{"rendered":"Use of fetchMore useQuery in nextJs"},"content":{"rendered":"\n<p>As We know hooks are very useful part in <a href=\"https:\/\/webkul.com\/headless-commerce-development-services\/\">Headless Development<\/a>. So, Here is an implementation of using the Pagination of Apollo Client in a convenient way. <\/p>\n\n\n\n<p>The fetchMore function of ApolloClient provides us an option to request the data with updated query parameters and to merge the results of the previous and latest responses.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">About fetchMore function &#8211;<\/h2>\n\n\n\n<p>Pagination always involves\u00a0<strong>sending follow-up queries to your GraphQL server to obtain additional pages of results<\/strong>. <\/p>\n\n\n\n<p>In Apollo Client, the recommended way to send these follow-up queries is with the fetchMore function.<br>You can go through the <a href=\"https:\/\/www.apollographql.com\/docs\/react\/pagination\/core-api\/#the-fetchmore-function\" rel=\"nofollow\">FetchMore<\/a> section of Apollo for in-depth knowledge.<\/p>\n\n\n\n<p>Let&#8217;s start with taking an example to implement the fetchMore function. The basic idea in this example is to simply get all posts by clicking the Load More Button.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Setup:<\/h2>\n\n\n\n<p>Let&#8217;s do the setup, I hope you all are aware to set up the Apollo Client, no worries if you are just beginning. Here is the official <a href=\"https:\/\/www.apollographql.com\/docs\/react\/get-started\/\" rel=\"nofollow\">link<\/a> of Apollo Client for setting up ApolloClient in <code>nextJs<\/code>.<\/p>\n\n\n\n<p>And, for next.js project setup you can checkout our another blog: <a href=\"https:\/\/webkul.com\/blog\/project-setup-next-js\/\">NextJs Setup<\/a><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">npm install @apollo\/client graphql \n\/\/To install apolloClient and graphql using the command in terminal.<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/\/_app.js file\n\nimport &quot;@\/styles\/globals.css&quot;\nimport {\n  ApolloProvider,\n  ApolloClient,\n  InMemoryCache,\n  gql,\n} from &quot;@apollo\/client&quot;;\n\nexport default function App({ Component, pageProps }) {\n  const client = new ApolloClient({\n    uri: &quot;https:\/\/graphqlzero.almansi.me\/api&quot;,\n    cache: new InMemoryCache(),\n  });\n\n  client\n    .query({\n      query: gql`\n        query Posts {\n          posts {\n            data {\n              id\n              title\n              body\n              user {\n                name\n                email\n                company {\n                  name\n                }\n                id\n              }\n            }\n            meta {\n              totalCount\n            }\n          }\n        }\n      `,\n    })\n    .then((result) =&gt; console.log(result));\n\n  return (\n    &lt;ApolloProvider client={client}&gt;\n      &lt;Component {...pageProps} \/&gt;\n    &lt;\/ApolloProvider&gt;\n  );\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Illustration of useQuery &amp; fetchMore:<\/h2>\n\n\n\n<p>In the _app.js file, we did the setup of creating an instance of <code>ApolloClient<\/code>, providing our URI and query to get fetched, and in response getting the result.<br><strong>Note<\/strong>: We have wrapped the Component inside our ApolloProvider to make the apolloClient global in the application.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">FetchMore Component to fetch the graphql Query:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/\/FetchMore.js\n\nimport { useQuery, gql } from &quot;@apollo\/client&quot;;\n\nexport const POSTS_QUERY = gql`\n  query Posts($Page: Int!, $Limit: Int!) {\n    posts(options: { paginate: { page: $Page, limit: $Limit } }) {\n      data {\n        id\n        title\n        body\n        user {\n          name\n          email\n          company {\n            name\n          }\n          id\n        }\n      }\n      meta {\n        totalCount\n      }\n    }\n  }\n`;\n\nexport default function FetchMore() {\n  const offset = 1;\n  const { loading, error, data, fetchMore } = useQuery(POSTS_QUERY, {\n    variables: { Page: offset, Limit: 3 },\n  });\n\n  const handleLoadMore = () =&gt; {\n    fetchMore({\n      variables: {\n        Page: offset + 1,\n      },\n      updateQuery: (prev, { fetchMoreResult }) =&gt; {\n        if (!fetchMoreResult) return prev;\n        return Object.assign({}, prev, {\n          posts: {\n            ...fetchMoreResult.posts,\n            data: &#091;...prev.posts.data, ...fetchMoreResult.posts.data],\n          },\n        });\n      },\n    });\n  };\n\n  if (loading) return &lt;p&gt;Loading...&lt;\/p&gt;;\n  if (error) return &lt;p&gt;Error : {error.message}&lt;\/p&gt;;\n\n  return (\n    &lt;&gt;\n      &lt;h1\n        style={{\n          textAlign: &quot;center&quot;,\n          textDecoration: &quot;underline&quot;,\n          marginTop: &quot;20px&quot;,\n        }}\n      &gt;\n        OUR BLOG SITE\n      &lt;\/h1&gt;\n      {data.posts.data.map(({ id, body, title, user }) =&gt; (\n        &lt;div style={{ padding: &quot;20px&quot; }} key={id}&gt;\n          &lt;h3&gt;\n            {id}. &lt;span style={{ textTransform: &quot;capitalize&quot; }}&gt;{title}&lt;\/span&gt;\n          &lt;\/h3&gt;\n          &lt;br \/&gt;\n          &lt;p style={{ textAlign: &quot;justify&quot; }}&gt;\n            &lt;span style={{ fontWeight: &quot;bold&quot; }}&gt;Blog: &lt;\/span&gt;\n            &lt;span&gt;{body}&lt;\/span&gt;\n          &lt;\/p&gt;\n          &lt;br \/&gt;\n          &lt;b&gt;About this user:&lt;\/b&gt;\n          &lt;p&gt;\n            &lt;b&gt;By: &lt;\/b&gt; &lt;span&gt;{user.name}&lt;\/span&gt;\n          &lt;\/p&gt;\n          &lt;br \/&gt;\n          &lt;hr \/&gt;\n        &lt;\/div&gt;\n      ))}\n      &lt;div style={{ alignItems: &quot;&quot;, paddingBottom: &quot;20px&quot; }}&gt;\n        &lt;center&gt;\n          &lt;button\n            style={{\n              padding: &quot;8px 10px&quot;,\n              fontSize: &quot;20px&quot;,\n              backgroundColor: &quot;green&quot;,\n              color: &quot;white&quot;,\n            }}\n            onClick={handleLoadMore}\n          &gt;\n            &lt;b&gt;Click to Load More&lt;\/b&gt;\n          &lt;\/button&gt;\n        &lt;\/center&gt;\n      &lt;\/div&gt;\n    &lt;\/&gt;\n  );\n}<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The FetchMore Component is responsible for first fetching the query using the useQuery Hook.<\/li>\n\n\n\n<li>By destructuring the useQuery Hook, we are taking out the <code>data<\/code>, <code>loading<\/code>, <code>error<\/code>, and <code>fetchMore<\/code> props of the hook.<\/li>\n\n\n\n<li>Initially, we pass the values of the variables for pageSize equal to 1 and limit 3. In this phase we get the data having 3 post items.<\/li>\n\n\n\n<li>Then we created a function to load more posts at the click of a button. Here comes the role of our <code>fetchMore<\/code> function, we are passing the value of query variables again. <\/li>\n\n\n\n<li>Further, we update the query response data, and in return, we get an updated response.<\/li>\n\n\n\n<li>On getting a new response, we simply added\/merged the previous and new responses as per need.<\/li>\n\n\n\n<li>In conclusion, we are receiving the next post entries on clicks.  <\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/\/pages\/post.js \n\nimport React from &quot;react&quot;;\nimport FetchMore from &quot;@\/components\/FetchMore&quot;;\n\nconst Post = () =&gt; {\n  return (\n    &lt;div&gt;\n     &lt;FetchMore\/&gt;\n    &lt;\/div&gt;\n  );\n};\n\nexport default Post;<\/pre>\n\n\n\n<p>In the post.js page, we have imported the FetchMore Component to render on the browser.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Output :<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"622\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png\" alt=\"Posts on clicking fetchMore\" class=\"wp-image-384753\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-300x155.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-250x130.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-768x398.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6.png 1287w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p class=\"has-text-align-center\">Posts fetched as per initial limit and page values passed.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img decoding=\"async\" width=\"1200\" height=\"622\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/FetchMoreBlog-1200x622.png\" alt=\"Posts on clicking fetchMore\" class=\"wp-image-384732\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/FetchMoreBlog-1200x622.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/FetchMoreBlog-300x155.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/FetchMoreBlog-250x130.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/FetchMoreBlog-768x398.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/FetchMoreBlog.png 1287w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n<\/div>\n\n\n<p class=\"has-text-align-center\">Posts fetched on click and get merged via updatedQuery, as per limit and page values passed in fetchMore Function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion &#8211;<\/h2>\n\n\n\n<p>I hope the example will be helpful for you to understand the key concept of <code>fetchMore<\/code> and <code>Pagination<\/code> in useQuery. <\/p>\n\n\n\n<p>In simple terms, since we need additional pages after we have fetched the initial data, pages, to achieve this we send follow-up queries using the <code>fetchMore<\/code> function of the <code>useQuery<\/code> hook. <\/p>\n\n\n\n<p>In addition, additional examples of use<code>FetchMore<\/code>\u00a0are provided in the detailed documentation for\u00a0<a href=\"https:\/\/www.apollographql.com\/docs\/react\/pagination\/offset-based\" rel=\"nofollow\">offset-based pagination<\/a>\u00a0and\u00a0<a href=\"https:\/\/www.apollographql.com\/docs\/react\/pagination\/cursor-based\" rel=\"nofollow\">cursor-based pagination<\/a>. If any doubts you can go through the <a href=\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\">blog<\/a> once again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As We know hooks are very useful part in Headless Development. So, Here is an implementation of using the Pagination of Apollo Client in a convenient way. The fetchMore function of ApolloClient provides us an option to request the data with updated query parameters and to merge the results of the previous and latest responses. <a href=\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":494,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13575,6357],"tags":[14290,14291,12682,14289,14292],"class_list":["post-384662","post","type-post","status-publish","format-standard","hentry","category-next-js","category-react-js","tag-apolloclient","tag-fetchmore","tag-nextjs","tag-reactjs","tag-usequery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Use of fetchMore useQuery in nextJs - Webkul Blog<\/title>\n<meta name=\"description\" content=\"how to implement the fetchMore function of the useQuery hook to update the query variables and merge the pagination response data.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Use of fetchMore useQuery in nextJs - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"how to implement the fetchMore function of the useQuery hook to update the query variables and merge the pagination response data.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-31T13:01:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-06-25T07:11:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png\" \/>\n<meta name=\"author\" content=\"Rajat Chaturvedi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rajat Chaturvedi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\"},\"author\":{\"name\":\"Rajat Chaturvedi\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/bceaf1c351d9bcf86cf2084a02915dab\"},\"headline\":\"Use of fetchMore useQuery in nextJs\",\"datePublished\":\"2023-05-31T13:01:13+00:00\",\"dateModified\":\"2024-06-25T07:11:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\"},\"wordCount\":497,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png\",\"keywords\":[\"apolloClient\",\"fetchMore\",\"nextjs\",\"reactjs\",\"useQuery\"],\"articleSection\":[\"next js\",\"react js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\",\"url\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\",\"name\":\"Use of fetchMore useQuery in nextJs - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png\",\"datePublished\":\"2023-05-31T13:01:13+00:00\",\"dateModified\":\"2024-06-25T07:11:33+00:00\",\"description\":\"how to implement the fetchMore function of the useQuery hook to update the query variables and merge the pagination response data.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6.png\",\"width\":1287,\"height\":667,\"caption\":\"Blog-6\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Use of fetchMore useQuery in nextJs\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/bceaf1c351d9bcf86cf2084a02915dab\",\"name\":\"Rajat Chaturvedi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/23c138c09b53f0dad5b70e6bdeed2c2c846c1950ff6009b9932cc7908e015cda?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/23c138c09b53f0dad5b70e6bdeed2c2c846c1950ff6009b9932cc7908e015cda?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Rajat Chaturvedi\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/rajatchaturvedi-mg758\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Use of fetchMore useQuery in nextJs - Webkul Blog","description":"how to implement the fetchMore function of the useQuery hook to update the query variables and merge the pagination response data.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/","og_locale":"en_US","og_type":"article","og_title":"Use of fetchMore useQuery in nextJs - Webkul Blog","og_description":"how to implement the fetchMore function of the useQuery hook to update the query variables and merge the pagination response data.","og_url":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-05-31T13:01:13+00:00","article_modified_time":"2024-06-25T07:11:33+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png","type":"","width":"","height":""}],"author":"Rajat Chaturvedi","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Rajat Chaturvedi","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/"},"author":{"name":"Rajat Chaturvedi","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/bceaf1c351d9bcf86cf2084a02915dab"},"headline":"Use of fetchMore useQuery in nextJs","datePublished":"2023-05-31T13:01:13+00:00","dateModified":"2024-06-25T07:11:33+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/"},"wordCount":497,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png","keywords":["apolloClient","fetchMore","nextjs","reactjs","useQuery"],"articleSection":["next js","react js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/","url":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/","name":"Use of fetchMore useQuery in nextJs - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6-1200x622.png","datePublished":"2023-05-31T13:01:13+00:00","dateModified":"2024-06-25T07:11:33+00:00","description":"how to implement the fetchMore function of the useQuery hook to update the query variables and merge the pagination response data.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Blog-6.png","width":1287,"height":667,"caption":"Blog-6"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/use-of-fetchmore-usequery-in-nextjs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Use of fetchMore useQuery in nextJs"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/bceaf1c351d9bcf86cf2084a02915dab","name":"Rajat Chaturvedi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/23c138c09b53f0dad5b70e6bdeed2c2c846c1950ff6009b9932cc7908e015cda?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/23c138c09b53f0dad5b70e6bdeed2c2c846c1950ff6009b9932cc7908e015cda?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Rajat Chaturvedi"},"url":"https:\/\/webkul.com\/blog\/author\/rajatchaturvedi-mg758\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/384662","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/494"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=384662"}],"version-history":[{"count":18,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/384662\/revisions"}],"predecessor-version":[{"id":449516,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/384662\/revisions\/449516"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=384662"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=384662"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=384662"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}