stacker.news/pages/_app.js

93 lines
2.7 KiB
JavaScript
Raw Normal View History

2021-04-14 00:57:32 +00:00
import '../styles/globals.scss'
2021-04-12 18:05:09 +00:00
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client'
import { Provider } from 'next-auth/client'
2021-05-20 21:32:59 +00:00
import { FundErrorModal, FundErrorProvider } from '../components/fund-error'
2021-05-25 00:08:56 +00:00
import { MeProvider } from '../components/me'
2021-07-15 20:49:13 +00:00
import PlausibleProvider from 'next-plausible'
import { LightningProvider } from '../components/lightning'
2021-04-12 18:05:09 +00:00
const client = new ApolloClient({
uri: '/api/graphql',
2021-06-22 17:47:49 +00:00
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
moreItems: {
keyArgs: ['sort', 'userId'],
merge (existing, incoming, { readField }) {
const items = existing ? existing.items : []
return {
cursor: incoming.cursor,
items: [...items, ...incoming.items]
}
},
read (existing) {
if (existing) {
return {
cursor: existing.cursor,
items: existing.items
}
}
}
2021-06-24 23:56:01 +00:00
},
moreFlatComments: {
keyArgs: ['userId'],
merge (existing, incoming, { readField }) {
const comments = existing ? existing.comments : []
return {
cursor: incoming.cursor,
comments: [...comments, ...incoming.comments]
}
},
read (existing) {
if (existing) {
return {
cursor: existing.cursor,
comments: existing.comments
}
}
}
},
notifications: {
merge (existing, incoming, { readField }) {
const notifications = existing ? existing.notifications : []
return {
cursor: incoming.cursor,
2021-08-20 00:13:32 +00:00
notifications: [...notifications, ...incoming.notifications],
lastChecked: incoming.lastChecked
}
},
read (existing) {
2021-08-20 00:13:32 +00:00
return existing
}
2021-06-22 17:47:49 +00:00
}
}
}
}
})
2021-04-12 18:05:09 +00:00
})
2021-03-22 20:36:10 +00:00
2021-03-25 19:29:24 +00:00
function MyApp ({ Component, pageProps }) {
2021-04-12 18:05:09 +00:00
return (
2021-07-15 20:49:13 +00:00
<PlausibleProvider domain='stacker.news' trackOutboundLinks>
<Provider session={pageProps.session}>
<ApolloProvider client={client}>
<MeProvider>
<LightningProvider>
<FundErrorProvider>
<FundErrorModal />
<Component {...pageProps} />
</FundErrorProvider>
</LightningProvider>
</MeProvider>
</ApolloProvider>
</Provider>
2021-07-15 20:49:13 +00:00
</PlausibleProvider>
2021-04-12 18:05:09 +00:00
)
2021-03-22 20:36:10 +00:00
}
export default MyApp