2018-02-24 23:17:04 +00:00
import App from '../components/App'
import Header from '../components/Header'
export default ( ) => (
< App >
< Header / >
< article >
< h1 > The Idea Behind This Example < / h 1 >
< p >
2018-08-09 21:00:08 +00:00
< a href = 'https://www.apollographql.com/client/' > Apollo < / a > i s a G r a p h Q L c l i e n t t h a t a l l o w s y o u t o e a s i l y q u e r y t h e e x a c t d a t a y o u n e e d f r o m a G r a p h Q L s e r v e r . I n a d d i t i o n t o f e t c h i n g a n d m u t a t i n g d a t a , A p o l l o a n a l y z e s y o u r q u e r i e s a n d t h e i r r e s u l t s t o c o n s t r u c t a c l i e n t - s i d e c a c h e o f y o u r d a t a , w h i c h i s k e p t u p t o d a t e a s f u r t h e r q u e r i e s a n d m u t a t i o n s a r e r u n , f e t c h i n g m o r e r e s u l t s f r o m t h e s e r v e r .
2018-02-24 23:17:04 +00:00
< / p >
< p >
In this simple example , we integrate Apollo seamlessly with < a href = 'https://github.com/zeit/next.js' > Next < /a> by wrapping our pages inside a <a href='https:/ / facebook . github . io / react / docs / higher - order - components . html '>higher-order component (HOC)</a>. Using the HOC pattern we' re able to pass down a central store of query result data created by Apollo into our React component hierarchy defined inside each page of our Next application .
< / p >
< p >
2018-08-09 21:00:08 +00:00
On initial page load , while on the server and inside getInitialProps , we invoke the Apollo method , < a href = 'https://www.apollographql.com/docs/react/features/server-side-rendering.html#getDataFromTree' > getDataFromTree < / a > . T h i s m e t h o d r e t u r n s a p r o m i s e ; a t t h e p o i n t i n w h i c h t h e p r o m i s e r e s o l v e s , o u r A p o l l o C l i e n t s t o r e i s c o m p l e t e l y i n i t i a l i z e d .
2018-02-24 23:17:04 +00:00
< / p >
< p >
This example relies on < a href = 'http://graph.cool' > graph . cool < / a > f o r i t s G r a p h Q L b a c k e n d .
< / p >
< / a r t i c l e >
< / A p p >
)