From 12ff827431bc2834855c946838b387cda8bbcf6d Mon Sep 17 00:00:00 2001 From: cascandaliato <8927157+cascandaliato@users.noreply.github.com> Date: Tue, 17 Nov 2020 14:00:54 +0100 Subject: [PATCH 1/3] Replace graph.cool endpoint with hasura.io --- examples/with-apollo-and-redux/README.md | 2 ++ .../with-apollo-and-redux/components/PostList.js | 16 +++++++++------- .../components/PostUpvoter.js | 4 ++-- .../with-apollo-and-redux/components/Submit.js | 6 +++--- examples/with-apollo-and-redux/lib/apollo.js | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/with-apollo-and-redux/README.md b/examples/with-apollo-and-redux/README.md index 622fd8c1528d8..627b996e222b6 100644 --- a/examples/with-apollo-and-redux/README.md +++ b/examples/with-apollo-and-redux/README.md @@ -4,6 +4,8 @@ This example serves as a conduit if you were using Apollo 1.X with Redux, and ar In 3.0.0, Apollo serves out-of-the-box support for redux in favor of Apollo's state management. This example aims to be an amalgamation of the [`with-apollo`](https://github.com/vercel/next.js/tree/master/examples/with-apollo) and [`with-redux`](https://github.com/vercel/next.js/tree/master/examples/with-redux) examples. +To inspect the GraphQL API, go to [Online GraphiQL](https://graphiql-online.com/) and enter `https://top-shepherd-94.hasura.app/v1/graphql` as API endpoint URL. + ## Deploy your own Deploy the example using [Vercel](https://vercel.com): diff --git a/examples/with-apollo-and-redux/components/PostList.js b/examples/with-apollo-and-redux/components/PostList.js index a2a264488f01e..f0197a8ea6399 100644 --- a/examples/with-apollo-and-redux/components/PostList.js +++ b/examples/with-apollo-and-redux/components/PostList.js @@ -4,15 +4,17 @@ import PostUpvoter from './PostUpvoter' export const ALL_POSTS_QUERY = gql` query allPosts($first: Int!, $skip: Int!) { - allPosts(orderBy: createdAt_DESC, first: $first, skip: $skip) { + Posts(offset: $skip, limit: $first, order_by: { createdAt: desc }) { id title votes url createdAt } - _allPostsMeta { - count + Posts_aggregate { + aggregate { + count + } } } ` @@ -38,7 +40,7 @@ export default function PostList() { const loadMorePosts = () => { fetchMore({ variables: { - skip: allPosts.length, + skip: Posts.length, }, }) } @@ -46,13 +48,13 @@ export default function PostList() { if (error) return if (loading && !loadingMorePosts) return
Loading
- const { allPosts, _allPostsMeta } = data - const areMorePosts = allPosts.length < _allPostsMeta.count + const { Posts, Posts_aggregate } = data + const areMorePosts = Posts.length < Posts_aggregate.count return (