fix apollo ssr client imports
This commit is contained in:
parent
ca1a95094c
commit
a226bac25d
|
@ -1,12 +1,13 @@
|
||||||
import { ITEM_FIELDS } from '../../../fragments/items'
|
import { ITEM_FIELDS } from '../../../fragments/items'
|
||||||
import { gql } from '@apollo/client'
|
import { gql } from '@apollo/client'
|
||||||
import ApolloClient from '../../../api/client'
|
import getSSRApolloClient from '../../../api/ssrApollo'
|
||||||
import { DiscussionForm } from '../../../components/discussion-form'
|
import { DiscussionForm } from '../../../components/discussion-form'
|
||||||
import { LinkForm } from '../../../components/link-form'
|
import { LinkForm } from '../../../components/link-form'
|
||||||
import LayoutCenter from '../../../components/layout-center'
|
import LayoutCenter from '../../../components/layout-center'
|
||||||
|
|
||||||
export async function getServerSideProps ({ req, params: { id } }) {
|
export async function getServerSideProps ({ req, params: { id } }) {
|
||||||
const { error, data: { item } } = await (await ApolloClient(req)).query({
|
const client = await getSSRApolloClient(req)
|
||||||
|
const { error, data: { item } } = await client.query({
|
||||||
query:
|
query:
|
||||||
gql`
|
gql`
|
||||||
${ITEM_FIELDS}
|
${ITEM_FIELDS}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
import ApolloClient from '../api/client'
|
import getSSRApolloClient from '../api/ssrApollo'
|
||||||
import generateRssFeed from '../lib/rss'
|
import generateRssFeed from '../lib/rss'
|
||||||
import { MORE_ITEMS } from '../fragments/items'
|
import { MORE_ITEMS } from '../fragments/items'
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@ export default function RssFeed () {
|
||||||
|
|
||||||
export async function getServerSideProps ({ req, res }) {
|
export async function getServerSideProps ({ req, res }) {
|
||||||
const emptyProps = { props: {} } // to avoid server side warnings
|
const emptyProps = { props: {} } // to avoid server side warnings
|
||||||
const { error, data: { moreItems: { items } } } = await (await ApolloClient(req)).query({
|
const client = await getSSRApolloClient(req)
|
||||||
|
const { error, data: { moreItems: { items } } } = await client.query({
|
||||||
query: MORE_ITEMS,
|
query: MORE_ITEMS,
|
||||||
variables: { sort: 'hot' }
|
variables: { sort: 'hot' }
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue