nikolasburk / relay-modern-migration-example

:memo: Todo example app built with React & Relay

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Migrating to Relay Modern

This repository contains 2 branches:

  • classic: Relay Classic
  • modern: Relay Modern

You can read the full tutorial describing the migration here.

Quickstart

1. Clone example repository

git clone https://github.com/graphcool-examples/react-relay-todo-quickstart.git
cd react-relay-todo-quickstart

2. Create GraphQL API with graphcool

# Install Graphcool CLI
npm install -g graphcool

# Create a new project based on the Todo schema
graphcool init --schema http://graphqlbin.com/todo.graphql

This creates a GraphQL API for the following schema:

type Todo {
  text: String!
  complete: Boolean!
}

3. Connect the app with your GraphQL API

Copy the Relay API endpoint to ./src/app.js as the argument for the constructor of Relay.DefaultNetworkLayer, replacing __RELAY_API_ENDPOINT__ :

// replace `__RELAY_API_ENDPOINT__ ` with the endpoint from the previous step
Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('__RELAY_API_ENDPOINT__')
);

Further, open package.json and paste the endpoint as the value for the url key, again replacing __RELAY_API_ENDPOINT__ :

"graphql": {
  "request": {
    "url": "__RELAY_API_ENDPOINT__"
  }
},

4. Install dependencies & run locally

yarn install
yarn start # open http://localhost:3000 in your browser

Next steps

Help & Community Slack Status

Say hello in our Slack or visit the Graphcool Forum if you run into issues or have questions. We love talking to you!

About

:memo: Todo example app built with React & Relay


Languages

Language:JavaScript 72.3%Language:CSS 26.6%Language:HTML 1.1%