Skip to content

Commit f884146

Browse files
authored
feat(apollo-link-accounts)!: update to use @apollo/client 3 (#1030)
1 parent 5841253 commit f884146

File tree

12 files changed

+387
-180
lines changed

12 files changed

+387
-180
lines changed

examples/graphql-server-typescript/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818
"@accounts/server": "^0.28.0",
1919
"@graphql-modules/core": "0.7.17",
2020
"@graphql-tools/merge": "6.0.11",
21-
"apollo-server": "2.14.4",
21+
"apollo-server": "2.16.0",
2222
"graphql": "14.6.0",
23-
"graphql-tools": "5.0.0",
24-
"lodash": "4.17.15",
25-
"mongoose": "5.9.13",
23+
"lodash": "4.17.19",
24+
"mongoose": "5.9.25",
2625
"tslib": "2.0.0"
2726
},
2827
"devDependencies": {
29-
"@types/mongoose": "5.7.16",
28+
"@types/mongoose": "5.7.32",
3029
"@types/node": "14.0.13",
31-
"nodemon": "2.0.3",
32-
"ts-node": "8.10.1",
33-
"typescript": "3.8.3"
30+
"nodemon": "2.0.4",
31+
"ts-node": "8.10.2",
32+
"typescript": "3.9.7"
3433
}
3534
}

examples/react-graphql-typescript/package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,25 @@
2828
"@accounts/client": "^0.28.0",
2929
"@accounts/client-password": "^0.28.0",
3030
"@accounts/graphql-client": "^0.28.0",
31-
"@apollo/react-hooks": "3.1.5",
32-
"@material-ui/core": "4.9.13",
33-
"@material-ui/styles": "4.9.13",
34-
"apollo-cache-inmemory": "1.6.6",
35-
"apollo-client": "2.6.9",
36-
"apollo-link": "1.2.14",
37-
"apollo-link-http": "1.5.17",
31+
"@apollo/client": "3.0.2",
32+
"@material-ui/core": "4.11.0",
33+
"@material-ui/styles": "4.10.0",
3834
"graphql": "14.6.0",
3935
"graphql-tag": "2.10.4",
4036
"qrcode.react": "1.0.0",
4137
"react": "16.13.1",
42-
"react-apollo": "2.5.8",
4338
"react-dom": "16.13.1",
44-
"react-router-dom": "5.1.2",
39+
"react-router-dom": "5.2.0",
4540
"tslib": "2.0.0"
4641
},
4742
"devDependencies": {
4843
"@types/node": "14.0.13",
49-
"@types/qrcode.react": "1.0.0",
50-
"@types/react": "16.9.36",
44+
"@types/qrcode.react": "1.0.1",
45+
"@types/react": "16.9.43",
5146
"@types/react-dom": "16.9.8",
52-
"@types/react-router": "5.1.7",
47+
"@types/react-router": "5.1.8",
5348
"@types/react-router-dom": "5.1.5",
5449
"react-scripts": "3.4.1",
55-
"typescript": "3.7.5"
50+
"typescript": "3.9.7"
5651
}
5752
}

examples/react-graphql-typescript/src/Home.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { RouteComponentProps, Link, Redirect } from 'react-router-dom';
33
import { Button, Typography } from '@material-ui/core';
44
import gql from 'graphql-tag';
5-
import { useQuery } from '@apollo/react-hooks';
5+
import { useQuery } from '@apollo/client';
66

77
import { accountsClient, accountsGraphQL } from './utils/accounts';
88

examples/react-graphql-typescript/src/TwoFactor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import QRCode from 'qrcode.react';
55
import { accountsGraphQL } from './utils/accounts';
66

77
const TwoFactor = () => {
8-
const [secret, setSecret] = useState();
8+
const [secret, setSecret] = useState<any>();
99
const [oneTimeCode, setOneTimeCode] = useState('');
1010

1111
const fetchTwoFactorSecret = async () => {
@@ -44,7 +44,7 @@ const TwoFactor = () => {
4444
<Input
4545
id="one-time-code"
4646
value={oneTimeCode}
47-
onChange={e => setOneTimeCode(e.target.value)}
47+
onChange={(e) => setOneTimeCode(e.target.value)}
4848
/>
4949
</FormControl>
5050
<Button onClick={onSetTwoFactor}>Submit</Button>

examples/react-graphql-typescript/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { ApolloProvider } from '@apollo/react-hooks';
3+
import { ApolloProvider } from '@apollo/client';
44
import { apolloClient } from './utils/accounts';
55
import Router from './Router';
66

examples/react-graphql-typescript/src/utils/accounts.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { AccountsClient } from '@accounts/client';
22
import { AccountsClientPassword } from '@accounts/client-password';
33
import GraphQLClient from '@accounts/graphql-client';
44
import { accountsLink } from '@accounts/apollo-link';
5-
import { ApolloClient } from 'apollo-client';
6-
import { HttpLink } from 'apollo-link-http';
7-
import { from } from 'apollo-link';
8-
import { InMemoryCache } from 'apollo-cache-inmemory';
5+
import { ApolloClient, InMemoryCache, HttpLink, from } from '@apollo/client';
96
import gql from 'graphql-tag';
107

118
// This auth link will inject the token in the headers on every request you make using apollo client

packages/apollo-link-accounts/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
"url": "https://github.com/accounts-js/accounts/tree/master/packages/apollo-link"
2424
},
2525
"license": "MIT",
26-
"devDependencies": {
27-
"@accounts/client": "^0.28.0",
28-
"apollo-link": "1.2.14",
29-
"rimraf": "3.0.2"
26+
"peerDependencies": {
27+
"@apollo/client": "^3.0.0"
3028
},
3129
"dependencies": {
32-
"apollo-link-context": "1.0.20",
3330
"tslib": "2.0.0"
31+
},
32+
"devDependencies": {
33+
"@accounts/client": "^0.28.0",
34+
"@apollo/client": "3.0.2",
35+
"rimraf": "3.0.2"
3436
}
3537
}

packages/apollo-link-accounts/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { setContext } from 'apollo-link-context';
2-
import { ApolloLink } from 'apollo-link';
1+
import { ApolloLink } from '@apollo/client';
2+
import { setContext } from '@apollo/client/link/context';
33
import { AccountsClient } from '@accounts/client';
44

55
type AccountsClientFactory = () => AccountsClient | Promise<AccountsClient>;

packages/e2e/__tests__/servers/server-graphql.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { AccountsGraphQLClient } from '@accounts/graphql-client';
55
import { AccountsPassword } from '@accounts/password';
66
import { AccountsServer } from '@accounts/server';
77
import { DatabaseInterface, User } from '@accounts/types';
8-
import ApolloClient from 'apollo-boost';
8+
import { ApolloClient, InMemoryCache } from '@apollo/client';
99
import { ApolloServer } from 'apollo-server';
1010
import fetch from 'node-fetch';
1111

@@ -82,7 +82,10 @@ export class ServerGraphqlTest implements ServerTestInterface {
8282
context,
8383
});
8484

85-
const apolloClient = new ApolloClient({ uri: `http://localhost:${this.port}` });
85+
const apolloClient = new ApolloClient({
86+
uri: `http://localhost:${this.port}`,
87+
cache: new InMemoryCache(),
88+
});
8689

8790
const accountsClientGraphQL = new AccountsGraphQLClient({
8891
graphQLClient: apolloClient,

packages/e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@
4747
"@accounts/server": "^0.28.0",
4848
"@accounts/typeorm": "^0.28.0",
4949
"@accounts/types": "^0.28.0",
50+
"@apollo/client": "3.0.2",
5051
"@graphql-modules/core": "0.7.17",
51-
"apollo-boost": "0.4.8",
5252
"apollo-server": "2.14.4",
5353
"body-parser": "1.19.0",
5454
"core-js": "3.6.5",

0 commit comments

Comments
 (0)