Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Upgrade Admin UI to Apollo Client 3 #3279

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo-projects/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@keystonejs/oembed-adapters": "^5.1.4",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-upload-client": "^13.0.0",
"apollo-upload-client": "^14.1.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrading these versions of apollo-upload-client so that all versions in the monorepo are the same

"cross-env": "^7.0.0",
"date-fns": "^2.14.0",
"dotenv": "^8.2.0",
Expand Down
2 changes: 1 addition & 1 deletion demo-projects/meetup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@keystonejs/session": "^8.0.0",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-upload-client": "^13.0.0",
"apollo-upload-client": "^14.1.0",
"body-parser": "^1.18.2",
"cross-env": "^7.0.0",
"date-fns": "^2.14.0",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"heroku-postbuild": "yarn build && yarn workspace @keystonejs/demo-project-blog build"
},
"dependencies": {
"@apollo/client": "^3.0.2",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@babel/helper-module-imports": "^7.8.3",
Expand Down
18 changes: 3 additions & 15 deletions packages/app-admin-ui/client/apolloClient.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
import { ApolloClient } from 'apollo-client';
import { ApolloLink } from 'apollo-link';
import { ApolloClient, ApolloLink, InMemoryCache } from '@apollo/client';
import { onError } from '@apollo/client/link/error';
import { createUploadLink } from 'apollo-upload-client';
import { onError } from 'apollo-link-error';
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';

import fetch from 'cross-fetch';

// This shouldn't be necessary, but it silences an annoying error from Apollo
// Client: https://github.com/apollographql/apollo-client/issues/3397#issuecomment-421433032
const fragmentMatcher = new IntrospectionFragmentMatcher({
Copy link
Contributor Author

@jordanoverbye jordanoverbye Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IntrospectionFragmentMatcher has been removed in Apollo Client v3. See here apollographql/apollo-client#5073

introspectionQueryResultData: {
__schema: {
types: [],
},
},
});

export const initApolloClient = ({ uri }) => {
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors) {
Expand All @@ -36,6 +24,6 @@ export const initApolloClient = ({ uri }) => {

return new ApolloClient({
link: ApolloLink.from([errorLink, httpLink]),
cache: new InMemoryCache({ fragmentMatcher }),
cache: new InMemoryCache(),
});
};
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/classes/List.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import gql from 'graphql-tag';
import { gql } from '@apollo/client';

import { arrayToObject, mapKeys, omit } from '@keystonejs/utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/components/CreateItemModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
forwardRef,
} from 'react';
import { useHistory } from 'react-router-dom';
import { useMutation } from '@apollo/react-hooks';
import { useMutation } from '@apollo/client';
import { useToasts } from 'react-toast-notifications';

import { Button, LoadingButton } from '@arch-ui/button';
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/components/DeleteItemModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useMutation } from '@apollo/react-hooks';
import { useMutation } from '@apollo/client';
import { Button } from '@arch-ui/button';
import Confirm from '@arch-ui/confirm';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useMutation } from '@apollo/react-hooks';
import { useMutation } from '@apollo/client';
import { Button } from '@arch-ui/button';
import Confirm from '@arch-ui/confirm';

Expand Down
3 changes: 1 addition & 2 deletions packages/app-admin-ui/client/components/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import { useAdminMeta } from '../providers/AdminMeta';
import { useResizeHandler, KEYBOARD_SHORTCUT } from '../hooks/ResizeHandler';
import { useScrollQuery } from '../hooks/ScrollQuery';

import { useQuery } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import { useQuery, gql } from '@apollo/client';

const TRANSITION_DURATION = '220ms';
const TRANSITION_EASING = 'cubic-bezier(0.2, 0, 0, 1)';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { Fragment, useMemo, useCallback, Suspense, useState } from 'react';
import { useMutation } from '@apollo/react-hooks';
import { useMutation } from '@apollo/client';
import { useToasts } from 'react-toast-notifications';
import { omit, arrayToObject, countArrays } from '@keystonejs/utils';

Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Suspense, useMemo } from 'react';
import ReactDOM from 'react-dom';
import { ApolloProvider } from '@apollo/react-hooks';
import { ApolloProvider } from '@apollo/client';
import { BrowserRouter, Redirect, Route, Switch, useParams } from 'react-router-dom';
import { ToastProvider } from 'react-toast-notifications';
import { Global } from '@emotion/core';
Expand Down
3 changes: 1 addition & 2 deletions packages/app-admin-ui/client/pages/Home/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useMemo } from 'react';
import { useQuery } from '@apollo/react-hooks';
import { useQuery, gql } from '@apollo/client';

import { Container, Grid, Cell } from '@arch-ui/layout';
import { PageTitle } from '@arch-ui/typography';
Expand All @@ -13,7 +13,6 @@ import { useAdminMeta } from '../../providers/AdminMeta';

import useResizeObserver from 'use-resize-observer';
import throttle from 'lodash.throttle';
import gql from 'graphql-tag';

const getCountQuery = lists => {
if (!lists) return null;
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/pages/Item/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { Fragment, Suspense, useMemo, useCallback, useState, useRef, useEffect } from 'react';
import { useMutation, useQuery } from '@apollo/react-hooks';
import { useMutation, useQuery } from '@apollo/client';
import { useHistory, useParams } from 'react-router-dom';
import { useToasts } from 'react-toast-notifications';
import memoizeOne from 'memoize-one';
Expand Down
3 changes: 1 addition & 2 deletions packages/app-admin-ui/client/pages/Signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import { Input } from '@arch-ui/input';
import { colors, gridSize } from '@arch-ui/theme';
import { PageTitle, Title } from '@arch-ui/typography';

import { useMutation } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import { useMutation, gql } from '@apollo/client';

import { upcase } from '@keystonejs/utils';

Expand Down
3 changes: 1 addition & 2 deletions packages/app-admin-ui/client/pages/Signout.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { jsx } from '@emotion/core';

import { Fragment } from 'react';

import { useMutation } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import { useMutation, gql } from '@apollo/client';

import { CheckIcon } from '@primer/octicons-react';
import { Button } from '@arch-ui/button';
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/providers/List.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useContext, createContext, useState } from 'react';
import { useQuery } from '@apollo/react-hooks';
import { useQuery } from '@apollo/client';

import { useListUrlState } from '../pages/List/dataHooks';
import { deconstructErrorsToDataShape, useListSelect } from '../util';
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/public.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useMemo, Suspense } from 'react';
import ReactDOM from 'react-dom';
import { ApolloProvider } from '@apollo/react-hooks';
import { ApolloProvider } from '@apollo/client';
import { BrowserRouter, Route, Switch } from 'react-router-dom';
import { ToastProvider } from 'react-toast-notifications';
import { Global } from '@emotion/core';
Expand Down
9 changes: 2 additions & 7 deletions packages/app-admin-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"node": ">=10.0.0"
},
"dependencies": {
"@apollo/react-hooks": "^3.1.5",
"@apollo/client": "^3.0.2",
"@arch-ui/alert": "^0.0.17",
"@arch-ui/badge": "^0.0.16",
"@arch-ui/button": "^0.0.20",
Expand Down Expand Up @@ -45,11 +45,7 @@
"@keystonejs/utils": "^5.4.2",
"@primer/octicons-react": "^10.0.0",
"@types/react": "^16.8.12",
"apollo-cache-inmemory": "^1.6.6",
"apollo-client": "^2.6.10",
"apollo-link": "^1.2.14",
"apollo-link-error": "^1.1.12",
"apollo-upload-client": "^13.0.0",
"apollo-upload-client": "^14.1.0",
"apply-ref": "^0.2.0",
"babel-loader": "^8.0.5",
"babel-plugin-emotion": "^10.0.27",
Expand All @@ -63,7 +59,6 @@
"falsey": "^1.0.0",
"file-loader": "^3.0.1",
"graphql": "^14.6.0",
"graphql-tag": "^2.10.3",
"html-webpack-plugin": "^4.2.0",
"lodash.debounce": "^4.0.8",
"lodash.set": "^4.3.2",
Expand Down
Loading