Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
74e0c6d6
Unverified
Commit
74e0c6d6
authored
Feb 09, 2021
by
Smit Barmase
Committed by
GitHub
Feb 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
with-apollo SSR example added. (#21956)
Co-authored-by:
Lee Robinson
<
me@leerob.io
>
parent
394bbf62
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
Header.js
examples/with-apollo/components/Header.js
+3
-0
ssr.js
examples/with-apollo/pages/ssr.js
+33
-0
No files found.
examples/with-apollo/components/Header.js
View file @
74e0c6d6
...
@@ -17,6 +17,9 @@ export default function Header() {
...
@@ -17,6 +17,9 @@ export default function Header() {
Client
-
Only
Client
-
Only
<
/a
>
<
/a
>
<
/Link
>
<
/Link
>
<
Link
href
=
"/ssr"
>
<
a
className
=
{
pathname
===
'/ssr'
?
'is-active'
:
''
}
>
SSR
<
/a
>
<
/Link
>
<
style
jsx
>
{
`
<
style
jsx
>
{
`
header {
header {
margin-bottom: 25px;
margin-bottom: 25px;
...
...
examples/with-apollo/pages/ssr.js
0 → 100644
View file @
74e0c6d6
import
App
from
'../components/App'
import
InfoBox
from
'../components/InfoBox'
import
Header
from
'../components/Header'
import
Submit
from
'../components/Submit'
import
PostList
,
{
ALL_POSTS_QUERY
,
allPostsQueryVars
,
}
from
'../components/PostList'
import
{
initializeApollo
,
addApolloState
}
from
'../lib/apolloClient'
const
SSRPage
=
()
=>
(
<
App
>
<
Header
/>
<
InfoBox
>
ℹ️
This
page
shows
how
to
use
SSR
with
Apollo
.
<
/InfoBox
>
<
Submit
/>
<
PostList
/>
<
/App
>
)
export
async
function
getServerSideProps
()
{
const
apolloClient
=
initializeApollo
()
await
apolloClient
.
query
({
query
:
ALL_POSTS_QUERY
,
variables
:
allPostsQueryVars
,
})
return
addApolloState
(
apolloClient
,
{
props
:
{},
})
}
export
default
SSRPage
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment