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-react-relay-network-modern
Juan Olvera 7e12997af6 Test updater script on examples folder (#5993)
I wrote a [script](https://github.com/j0lv3r4/dependency-version-updater) to update dependencies recursively in `package.json` files, e.g.:

```
$ node index.js --path="./examples" --dependencies="react=^16.7.0,react-dom=^16.7.0"
```

This PR contains the result against the examples folder.
2019-01-05 12:19:27 +01:00
..
components Add prettier for examples directory (#5909) 2018-12-17 17:34:32 +01:00
lib/createEnvironment Add prettier for examples directory (#5909) 2018-12-17 17:34:32 +01:00
pages Add prettier for examples directory (#5909) 2018-12-17 17:34:32 +01:00
schema feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00
.babelrc feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00
.env feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00
.gitignore feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00
.graphqlconfig feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00
next.config.js feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00
package.json Test updater script on examples folder (#5993) 2019-01-05 12:19:27 +01:00
README.md feat(example): add react-relay-network-modern example (#5349) 2018-11-25 15:14:36 +01:00

Deploy to now

Relay Modern 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 with-relay-modern-app
# or
yarn create next-app --example with-relay-modern with-relay-modern-app

Download manually

Download the example:

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

Install it:

npm install
# or
yarn

Download schema introspection data from configured Relay endpoint

npm run schema
# or
yarn schema

Run Relay ahead-of-time compilation (should be re-run after any edits to components that query data with Relay)

npm run relay
# or
yarn relay

Run the project

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 relies on graph.cool for its GraphQL backend.