Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions samples/relay-modern-starter-kit/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"passPerPreset": true,
"presets": [
{
"plugins": [
["relay", {
"schema": "data/schema.json"}
],
"syntax-async-functions",
"transform-class-properties",
"transform-object-rest-spread",
"react-require"
]
},
"react",
"es2015",
"stage-0"
]
}
6 changes: 6 additions & 0 deletions samples/relay-modern-starter-kit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.DS_Store
node_modules
npm-debug.log
data/schema.graphql
.idea/
__generated__/
31 changes: 31 additions & 0 deletions samples/relay-modern-starter-kit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
BSD License

For Relay Starter Kit software

Copyright (c) 2013-2015, Facebook, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name Facebook nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 changes: 33 additions & 0 deletions samples/relay-modern-starter-kit/PATENTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Additional Grant of Patent Rights Version 2

"Software" means the Relay Starter Kit software distributed by Facebook, Inc.

Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software
("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable
(subject to the termination provision below) license under any Necessary
Claims, to make, have made, use, sell, offer to sell, import, and otherwise
transfer the Software. For avoidance of doubt, no license is granted under
Facebook's rights in any patent claims that are infringed by (i) modifications
to the Software made by you or any third party or (ii) the Software in
combination with any software or other technology.

The license granted hereunder will terminate, automatically and without notice,
if you (or any of your subsidiaries, corporate affiliates or agents) initiate
directly or indirectly, or take a direct financial interest in, any Patent
Assertion: (i) against Facebook or any of its subsidiaries or corporate
affiliates, (ii) against any party if such Patent Assertion arises in whole or
in part from any software, technology, product or service of Facebook or any of
its subsidiaries or corporate affiliates, or (iii) against any party relating
to the Software. Notwithstanding the foregoing, if Facebook or any of its
subsidiaries or corporate affiliates files a lawsuit alleging patent
infringement against you in the first instance, and you respond by filing a
patent infringement counterclaim in that lawsuit against that party that is
unrelated to the Software, the license granted hereunder will not terminate
under section (i) of this paragraph due to such counterclaim.

A "Necessary Claim" is a claim of a patent owned by Facebook that is
necessarily infringed by the Software standing alone.

A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
or contributory infringement or inducement to infringe any patent, including a
cross-claim or counterclaim.
81 changes: 81 additions & 0 deletions samples/relay-modern-starter-kit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Relay Modern Starter Kit with Pagination

This kit includes an app server, a GraphQL server, and a transpiler that you can use to get started building an app with Relay. For a walkthrough, see the [Relay tutorial](https://facebook.github.io/relay/docs/tutorial.html).

Few changes have been made to the original starter kit. It is now compatible with the [Relay Modern](https://facebook.github.io/relay/docs/relay-modern.html) API version. It also uses a [PaginationContainer](https://facebook.github.io/relay/docs/PaginationContainer.html) for item retrieving.

## Installation

First install required npm modules:

```
npm install
```

Generate JavaScript sources of Relay-wrapped components by executing:

```
npm run relay
```

## Running

Start the GraphQL server by executing:

```
fsharpi server.fsx
```

Start the Relay application server:

```
npm start
```

Visit `localhost:8090` in your browser in order to access the application.

## Developing

### GraphQL Server

Following information supposed to get you started with modification of the GraphQL server.

#### Debugging

The sample contains a `server.fs` copy of the server and an F# project file which can be used for debugging with mono:

```
xbuild && mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555 ./bin/Debug/mono/FSharp.Data.GraphQL.ModernRelay.exe
```

This will start the server awaiting for the mono debugger to be attached.

#### Uri

By default the server will start on `localhost:8083`. This can be modified by changing `address` and `port` in `server.fsx` or `server.fs` respectively. Changing this settings requires adjustment of `graphqlServerUri` in `./src/relayEnvironment.jsx`.

### Relay Application

#### Schema modification

Each time the schema is modified in the `server.fsx` GraphQL server, a new schema file has to be generated on the Relay application side.

Accessing the `localhost:8083` in your browser will yield an introspection reply containing the schema of the database. Save this response to `./data/schema.json` whenever the schema is getting changed.

Relay API has to know the path to the schema file. `.babelrc` contains this information by setting the `relay` plugin with `schema` option. Adjust this if the path to schema should change.

The generated `./data/schema.json` or `./data/schema.graphql` (see optional below) file is used for the ahead-of-time compilation by Relay Modern compiler. The compilation process should be triggered by executing:

```
npm run relay
```

The command checks relevant `.jsx` and `.js` files in `./src` folder and generates their compiled in `__generated__` for defined containers. Those are e.g. [FragmentContainer](https://facebook.github.io/relay/docs/fragment-container.html) or the root Relay tree [QueryRenderer](https://facebook.github.io/relay/docs/query-renderer.html).

#### Optional

There are two accepted schema formats: `.json` and `.graphql`. The conversion to the latter can be done by executing `npm run json-to-graphql`. Input and output files can be adjusted in `./scripts/jsonToGraphql.js`.

## License

Relay Starter Kit is [BSD licensed](./LICENSE). We also provide an additional [patent grant](./PATENTS).
Loading