Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 422d1a7

Browse files
authored
Merge pull request #79 from relay-tools/update-example
[WIP] Update example app with latest changes.
2 parents 7f71c0d + ad59f27 commit 422d1a7

File tree

9 files changed

+3873
-1392
lines changed

9 files changed

+3873
-1392
lines changed

README.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
[![Build Status](https://travis-ci.org/relay-tools/relay-compiler-language-typescript.svg?branch=master)](https://travis-ci.org/relay-tools/relay-compiler-language-typescript)
44

5-
A language plugin for [Relay](https://facebook.github.io/relay/) that adds TypeScript support, including emitting type
6-
definitions.
5+
A language plugin for [Relay](https://facebook.github.io/relay/) that adds
6+
TypeScript support, including emitting type definitions.
77

88
## Installation
99

@@ -23,24 +23,26 @@ Then configure your `relay-compiler` script to use it, like so:
2323
```json
2424
{
2525
"scripts": {
26-
"relay": "relay-compiler --src ./src --schema data/schema.graphql --language typescript --artifactDirectory ./src/__generated__"
26+
"relay":
27+
"relay-compiler --src ./src --schema data/schema.graphql --language typescript --artifactDirectory ./src/__generated__"
2728
}
2829
}
2930
```
3031

31-
This is going to store all artifacts in a single directory, which you also need to instruct `babel-plugin-relay` to use in your `.babelrc`:
32+
This is going to store all artifacts in a single directory, which you also need
33+
to instruct `babel-plugin-relay` to use in your `.babelrc`:
3234

3335
```json
3436
{
35-
"plugins": [
36-
["relay", { "artifactDirectory": "./src/__generated__" }]
37-
]
37+
"plugins": [["relay", { "artifactDirectory": "./src/__generated__" }]]
3838
}
3939
```
4040

4141
### TypeScript
4242

43-
Also be sure to configure the TypeScript compiler to transpile to `es2015` modules and leave transpilation to `commonjs` modules up to Babel with the following `tsconfig.json` settings:
43+
Also be sure to configure the TypeScript compiler to transpile to `es2015`
44+
modules and leave transpilation to `commonjs` modules up to Babel with the
45+
following `tsconfig.json` settings:
4446

4547
```json
4648
{
@@ -51,34 +53,54 @@ Also be sure to configure the TypeScript compiler to transpile to `es2015` modul
5153
}
5254
```
5355

54-
The reason for this is that `tsc` would otherwise generate code where the imported `graphql` function is being namespaced (`react_relay_1` in this example):
56+
The reason for this is that `tsc` would otherwise generate code where the
57+
imported `graphql` function is being namespaced (`react_relay_1` in this
58+
example):
5559

5660
```js
57-
react_relay_1.createFragmentContainer(MyComponent, react_relay_1.graphql `
61+
react_relay_1.createFragmentContainer(
62+
MyComponent,
63+
react_relay_1.graphql`
5864
...
59-
`);
65+
`
66+
);
6067
```
6168

62-
…and this makes it impossible for `babel-plugin-relay` to find the locations where the `graphql` function is being used.
69+
…and this makes it impossible for `babel-plugin-relay` to find the locations
70+
where the `graphql` function is being used.
6371

64-
Note that this does mean you need to configure Babel to transform the ES module `import` and `export` statements, by using the [`babel-plugin-transform-es2015-modules-commonjs`](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/) transform plugin, if you’re not already.
72+
Note that this does mean you need to configure Babel to transform the ES module
73+
`import` and `export` statements, by using the
74+
[`babel-plugin-transform-es2015-modules-commonjs`](https://babeljs.io/docs/plugins/transform-es2015-modules-commonjs/)
75+
transform plugin, if you’re not already.
6576

6677
## Problems
6778

6879
### React Hot Loader
6980

70-
React Hot Loader is known to not always work well with generated code such as our typing artefacts, which will lead to loading modules _with_ TypeScript types into the browser and break. As a maintainer of RHL [pointed out](https://github.com/gaearon/react-hot-loader/issues/1032) in a similar issue:
81+
React Hot Loader is known to not always work well with generated code such as
82+
our typing artefacts, which will lead to loading modules _with_ TypeScript types
83+
into the browser and break. As a maintainer of RHL
84+
[pointed out](https://github.com/gaearon/react-hot-loader/issues/1032) in a
85+
similar issue:
7186

72-
> The problem - hot reloading is not "complete"
87+
> The problem - hot reloading is not "complete"
7388
74-
So [until RHL will be made “complete”](https://github.com/gaearon/react-hot-loader/issues/1024) this project can’t gurantee to always work well with it, nor is it our control to do anything about that.
89+
So
90+
[until RHL will be made “complete”](https://github.com/gaearon/react-hot-loader/issues/1024)
91+
this project can’t gurantee to always work well with it, nor is it our control
92+
to do anything about that.
7593

76-
## Examples
94+
## Also see
7795

78-
You can find a copy of the Relay
79-
[example TODO app](https://github.com/kastermester/relay-compiler-language-typescript/tree/master/example) inside this
80-
repository or you can take a look at the [Artsy React Native app](https://github.com/artsy/emission).
96+
* You can find a copy of the Relay
97+
[example TODO app](https://github.com/kastermester/relay-compiler-language-typescript/tree/master/example)
98+
inside this repository or you can take a look at the
99+
[Artsy React Native app](https://github.com/artsy/emission).
100+
* There are Relay tslint rules available
101+
[here](https://github.com/relay-tools/tslint-plugin-relay).
81102

82103
## License
83104

84-
This package is available under the MIT license. See the included LICENSE file for details.
105+
This package is available under the MIT license. See the included LICENSE file
106+
for details.

example/.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/.eslintrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

example/package.json

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,38 @@
22
"private": true,
33
"scripts": {
44
"start": "babel-node ./server.js",
5-
"build": "relay-compiler --src ./ts/ --schema ./data/schema.graphql --language typescript --artifactDirectory ./ts/__relay_artifacts__",
5+
"build":
6+
"relay-compiler --src ./ts/ --schema ./data/schema.graphql --language typescript --artifactDirectory ./ts/__relay_artifacts__",
67
"update-schema": "babel-node ./scripts/updateSchema.js",
7-
"lint": "eslint ./js",
8+
"lint": "tslint --project tsconfig.json",
89
"type-check": "tsc --noEmit --pretty"
910
},
1011
"resolutions": {
11-
"graphql": "^0.13.1",
12-
"relay-compiler-language-typescript": "file:../relay-compiler-language-typescript-1.1.0-alpha.1.tgz",
13-
"relay-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-compiler-1.6.1-plugin.1.tgz",
14-
"graphql-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/graphql-compiler-1.6.1-plugin.1.tgz",
15-
"relay-runtime": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-runtime-1.6.1-plugin.1.tgz",
16-
"babel-plugin-relay": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/babel-plugin-relay-1.6.1-plugin.1.tgz",
17-
"react-relay": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/react-relay-1.6.1-plugin.1.tgz"
12+
"relay-compiler-language-typescript":
13+
"file:../relay-compiler-language-typescript-v1.1.1-alpha.2.tgz"
1814
},
1915
"dependencies": {
16+
"@babel/core": "^7.0.0-0",
2017
"babel-core": "^6.26.0",
2118
"babel-loader": "^7.1.2",
22-
"babel-plugin-relay": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/babel-plugin-relay-1.6.1-plugin.1.tgz",
19+
"babel-plugin-relay": "^2.0.0-rc.1",
2320
"babel-plugin-transform-runtime": "^6.12.0",
2421
"babel-preset-es2015": "^6.13.2",
2522
"babel-preset-react": "^6.11.1",
2623
"babel-preset-stage-0": "^6.5.0",
2724
"babel-runtime": "^6.26.0",
2825
"classnames": "2.2.5",
2926
"express": "^4.15.2",
30-
"express-graphql": "^0.6.4",
31-
"graphql": "^0.13.1",
32-
"graphql-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/graphql-compiler-1.6.1-plugin.1.tgz",
33-
"graphql-relay": "^0.5.1",
27+
"express-graphql": "^0.7.1",
28+
"graphql": "^14.0.2",
29+
"graphql-compiler": "^2.0.0-rc.1",
30+
"graphql-relay": "^0.5.5",
3431
"prop-types": "^15.6.2",
3532
"react": "^16.4.1",
3633
"react-dom": "^16.4.1",
37-
"react-relay": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/react-relay-1.6.1-plugin.1.tgz",
34+
"react-relay": "^2.0.0-rc.1",
3835
"relay-devtools": "^1.4.0",
39-
"relay-runtime": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-runtime-1.6.1-plugin.1.tgz",
36+
"relay-runtime": "^2.0.0-rc.1",
4037
"todomvc-app-css": "^2.1.0",
4138
"todomvc-common": "^1.0.3",
4239
"webpack": "^3.5.5",
@@ -52,15 +49,13 @@
5249
"babel-cli": "^6.26.0",
5350
"babel-eslint": "6.1.2",
5451
"csstype": "^2.5.6",
55-
"eslint": "3.19.0",
56-
"eslint-config-fbjs": "1.1.1",
57-
"eslint-plugin-babel": "3.3.0",
58-
"eslint-plugin-flowtype": "2.15.0",
59-
"eslint-plugin-react": "5.2.2",
6052
"fork-ts-checker-webpack-plugin": "^0.3.0",
61-
"relay-compiler": "https://github.com/alloy/relay/releases/download/v1.6.1-plugin.1/relay-compiler-1.6.1-plugin.1.tgz",
62-
"relay-compiler-language-typescript": "file:../relay-compiler-language-typescript-1.1.0-alpha.1.tgz",
53+
"relay-compiler": "^2.0.0-rc.1",
54+
"relay-compiler-language-typescript":
55+
"file:../relay-compiler-language-typescript-v1.1.1-alpha.2.tgz",
6356
"ts-loader": "^3.2.0",
57+
"tslint": "^5.12.0",
58+
"tslint-plugin-relay": "^0.0.3",
6459
"typescript": "2.9.1"
6560
}
6661
}

example/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
"strict": true,
88
"target": "es2015"
99
},
10-
"exclude": [
11-
"node_modules"
12-
]
10+
"exclude": ["node_modules"]
1311
}

example/tslint.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"defaultSeverity": "error",
3+
"extends": ["tslint:recommended", "tslint-plugin-relay"],
4+
"jsRules": {},
5+
"rules": {
6+
"arrow-parens": false,
7+
"interface-name": false,
8+
"object-literal-sort-keys": false,
9+
"variable-name": false,
10+
"trailing-comma": false,
11+
"quotemark": false,
12+
"ordered-imports": false,
13+
"no-console": false,
14+
"semicolon": false,
15+
"member-access": false,
16+
"curly": false,
17+
"object-literal-shorthand": false
18+
},
19+
"rulesDirectory": []
20+
}

0 commit comments

Comments
 (0)