1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-relay-modern-server-express
Petr Messner 968475fb95 Update with-relay-modern and with-relay-modern-server-express (#6182)
Update examples with-relay-modern and with-relay-modern-server-express to react-relay 2.0.0

- react-relay has started to use new Context API instead of Legacy Context API
- add `parseInt` because graphql 14.0.0 introduced stricter scalar value coercion

Closes #6157
2019-01-31 10:38:19 +01:00
..
components Add prettier for examples directory (#5909) 2018-12-17 17:34:32 +01:00
lib Update with-relay-modern and with-relay-modern-server-express (#6182) 2019-01-31 10:38:19 +01:00
pages Update with-relay-modern and with-relay-modern-server-express (#6182) 2019-01-31 10:38:19 +01:00
server Add prettier for examples directory (#5909) 2018-12-17 17:34:32 +01:00
.babelrc Added a new example with relay modern and a graphql server with express. (#4670) 2018-12-10 16:50:35 +01:00
.env Added a new example with relay modern and a graphql server with express. (#4670) 2018-12-10 16:50:35 +01:00
.gitignore Added a new example with relay modern and a graphql server with express. (#4670) 2018-12-10 16:50:35 +01:00
next.config.js Add prettier for examples directory (#5909) 2018-12-17 17:34:32 +01:00
package.json Update with-relay-modern and with-relay-modern-server-express (#6182) 2019-01-31 10:38:19 +01:00
README.md Added a new example with relay modern and a graphql server with express. (#4670) 2018-12-10 16:50:35 +01:00

Deploy to now

Relay Modern Server Express Example

How to use

Using create-next-app

Execute create-next-app with Yarn or npx to bootstrap the example:

npx create-next-app --example with-relay-modern-server-express with-relay-modern-server-express-app
# or
yarn create next-app --example with-relay-modern-server-express with-relay-modern-server-express-app

Download manually

Download the example or clone the repo:

curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/with-relay-modern-server-express
cd with-relay-modern-server-express

Install it:

npm install
# or
yarn

Run the project (it runs automatically the Relay ahead-of-time compilation)

npm run dev
# or
yarn dev

Deploy it to the cloud with now (download):

now

The idea behind the example

Relay Modern is a new version of Relay designed from the ground up to be easier to use, more extensible and, most of all, able to improve performance on mobile devices. Relay Modern accomplishes this with static queries and ahead-of-time code generation.

In this simple example, we integrate Relay Modern seamlessly with Next by wrapping our pages inside a higher-order component (HOC). Using the HOC pattern we're able to pass down a query result data created by Relay into our React component hierarchy defined inside each page of our Next application. The HOC takes options argument that allows to specify a query that will be executed on the server when a page is being loaded.

This example implements a simple graphql server using express, showing a custom graphql server integrated to next.js and relay modern.