Skip to content

Commit 6fb8177

Browse files
committed
Add cross-fetch and remove code that doesn't work server-side
1 parent 2d1ab7d commit 6fb8177

File tree

4 files changed

+5
-77
lines changed

4 files changed

+5
-77
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ npm-debug.log*
2020
yarn-debug.log*
2121
yarn-error.log*
2222

23-
.env*
23+
.env*
24+
.vercel

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"classnames": "^2.2.6",
2929
"cloudinary-core": "^2.11.3",
3030
"cloudinary-react": "^1.6.8",
31+
"cross-fetch": "^3.0.6",
3132
"date-fns": "^2.16.1",
3233
"eslint-plugin-graphql": "^4.0.0",
3334
"graphql": "^15.4.0",

src/lib/auth.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ const client = new auth0.WebAuth({
1616
scope: 'openid profile guide',
1717
})
1818

19-
initAuthHelpers({
20-
client,
21-
usePopup: true,
22-
authOptions: {
23-
connection: 'github',
24-
owp: true,
25-
popupOptions: { height: 623 }, // make tall enough for content
26-
},
27-
checkSessionOptions: {
28-
redirect_uri: window.location.origin,
29-
},
30-
onError: (e) => console.error(e),
31-
})
32-
3319
export const loginInProgressVar = makeVar(false)
3420

3521
export const login = () => {

src/lib/link.js

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,2 @@
1-
import { HttpLink, split, ApolloLink } from '@apollo/client'
2-
import { WebSocketLink } from '@apollo/client/link/ws'
3-
import { setContext } from '@apollo/client/link/context'
4-
import { getMainDefinition } from '@apollo/client/utilities'
5-
import { getAuthToken } from 'auth0-helpers'
6-
import { RestLink } from 'apollo-link-rest'
7-
8-
import { errorLink } from './errorLink'
9-
10-
export const spaceXLink = ApolloLink.from([
11-
errorLink,
12-
new HttpLink({
13-
uri: 'https://api.spacex.land/graphql',
14-
}),
15-
])
16-
17-
const httpLink = new HttpLink({
18-
uri: 'https://api.graphql.guide/graphql',
19-
})
20-
21-
const authLink = setContext(async (_, { headers }) => {
22-
const token = await getAuthToken({
23-
doLoginIfTokenExpired: true,
24-
})
25-
26-
if (token) {
27-
return {
28-
headers: {
29-
...headers,
30-
authorization: `Bearer ${token}`,
31-
},
32-
}
33-
} else {
34-
return { headers }
35-
}
36-
})
37-
38-
const authedHttpLink = authLink.concat(httpLink)
39-
40-
const wsLink = new WebSocketLink({
41-
uri: `wss://api.graphql.guide/subscriptions`,
42-
options: {
43-
reconnect: true,
44-
},
45-
})
46-
47-
const networkLink = split(
48-
({ query }) => {
49-
const { kind, operation } = getMainDefinition(query)
50-
return kind === 'OperationDefinition' && operation === 'subscription'
51-
},
52-
wsLink,
53-
authedHttpLink
54-
)
55-
56-
const restLink = new RestLink({
57-
uri: 'https://api.openweathermap.org/data/2.5/',
58-
})
59-
60-
const link = ApolloLink.from([errorLink, restLink, networkLink])
61-
62-
export default link
1+
export const spaceXLink = {}
2+
export default {}

0 commit comments

Comments
 (0)