Skip to content

Commit a6ac9f4

Browse files
committed
💡 chore: upgrade apollo client
1 parent 868c31c commit a6ac9f4

9 files changed

Lines changed: 45 additions & 203 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ run `yarn start` or `npm start` command to start a local server and get a test!
9898

9999
### :package: Packages
100100
- [Apollo](https://www.apollographql.com/docs/react/)
101-
- [React Helmet Async](https://github.com/staylor/react-helmet-async)
101+
- [React Helmet](https://github.com/nfl/react-helmet)
102102
- [React Icons](https://react-icons.netlify.com/#/)
103103
- [Styled Compoments](https://www.styled-components.com/)
104104
- [Polished](https://polished.js.org/)
@@ -113,7 +113,7 @@ run `yarn start` or `npm start` command to start a local server and get a test!
113113
- [Page Creator](https://www.gatsbyjs.org/packages/gatsby-plugin-page-creator/)
114114
- [Polished](https://www.gatsbyjs.org/packages/gatsby-plugin-polished/)
115115
- [Preload Fonts](https://www.gatsbyjs.org/packages/gatsby-plugin-preload-fonts/)
116-
- [React Helmet Async](https://www.gatsbyjs.org/packages/gatsby-plugin-sharp/)
116+
- [React Helmet](https://www.gatsbyjs.org/packages/gatsby-plugin-react-helmet/)
117117
- [Sharp](https://www.gatsbyjs.org/packages/gatsby-plugin-sharp/)
118118
- [Styled Components](https://www.gatsbyjs.org/packages/gatsby-plugin-styled-components/)
119119

font-preload-cache.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"timestamp":1585927005472,"hash":"53260b0eb5ca3cf626e0786300172b67","assets":{"/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true}}}
1+
{"timestamp":1598194155286,"hash":"9793e6f763870c321663cfe5f7b34b4c","assets":{"/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true},"/dev-404-page/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true},"/404/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true},"/battlefield/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true,"/static/lato-latin-400-b4d2c4c39853ee244272c04999b230ba.woff2":true},"/fighters/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true},"/result/":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true},"/404.html":{"/static/lato-latin-700-1efbd38aa76ddae2580fedf378276333.woff2":true}}}

gatsby/wrapRootElement.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
2-
import { ApolloProvider } from 'react-apollo';
2+
import { ApolloProvider } from '@apollo/client';
33
import { ThemeProvider } from 'styled-components';
44

5-
import { client } from '../src/hooks/apollo';
5+
import apolloClient from '../src/service/apolloClient';
66
import { RepositoryProvider } from '../src/hooks/repository';
77
import theme from '../src/styles/theme';
88

@@ -12,7 +12,7 @@ interface Props {
1212

1313
export const wrapRootElement: React.FC<Props> = ({ element }) => (
1414
<ThemeProvider theme={theme}>
15-
<ApolloProvider client={client}>
15+
<ApolloProvider client={apolloClient}>
1616
<RepositoryProvider>{element}</RepositoryProvider>
1717
</ApolloProvider>
1818
</ThemeProvider>

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"version": "1.0.0",
66
"author": "Henrique Miranda <hey@thehenry.dev>",
77
"dependencies": {
8-
"@apollo/react-hooks": "^3.1.4",
9-
"apollo-boost": "^0.4.7",
8+
"@apollo/client": "^3.1.3",
109
"babel-plugin-polished": "^1.1.0",
1110
"dotenv": "^8.2.0",
1211
"gatsby": "^2.24.47",
@@ -30,7 +29,6 @@
3029
"isomorphic-fetch": "^2.2.1",
3130
"polished": "^3.6.5",
3231
"react": "^16.12.0",
33-
"react-apollo": "^3.1.4",
3432
"react-dom": "^16.12.0",
3533
"react-helmet": "^6.1.0",
3634
"react-icons": "^3.11.0",

src/components/SearchRepository/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect, useMemo } from 'react';
22
import { FaSearch, FaSpinner } from 'react-icons/fa';
33

4-
import { useLazyQuery } from '@apollo/react-hooks';
4+
import { useLazyQuery } from '@apollo/client';
55
import gql from 'graphql-tag';
66

77
import { useRepository } from '~/hooks/repository';

src/hooks/apollo.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/pages/fighters/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useMemo } from 'react';
22

3-
import { useQuery } from '@apollo/react-hooks';
3+
import { useQuery } from '@apollo/client';
44
import gql from 'graphql-tag';
55

66
import Button from '~/components/Button';

src/service/apolloClient.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import {
2+
ApolloClient,
3+
ApolloLink,
4+
concat,
5+
HttpLink,
6+
InMemoryCache,
7+
} from '@apollo/client';
8+
import fetch from 'isomorphic-fetch';
9+
10+
const httpLink = new HttpLink({
11+
uri: 'https://api.github.com/graphql',
12+
fetch,
13+
});
14+
15+
/**
16+
* An auth middleware for add the GitHub token on the requests
17+
*/
18+
const authMiddleware = new ApolloLink((operation, forward) => {
19+
operation.setContext({
20+
headers: {
21+
authorization: `token ${process.env.GATSBY_GITHUB_TOKEN}`,
22+
},
23+
});
24+
25+
return forward(operation);
26+
});
27+
28+
export default new ApolloClient({
29+
link: concat(authMiddleware, httpLink),
30+
cache: new InMemoryCache(),
31+
});

0 commit comments

Comments
 (0)