You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 31, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+38-5Lines changed: 38 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ https://reactql.org
13
13
14
14
-[React v16](https://facebook.github.io/react/) for UI.
15
15
-[Apollo Client 2.0 (React)](http://dev.apollodata.com/react/) for connecting to GraphQL.
16
-
-[MobX](https://mobx.js.org/) for declarative, type-safe flux/store state management (automatically re-hydrated from the server.)
16
+
-[MobX](https://mobx.js.org/) for declarative, type-safe flux/store state management (automatically re-hydrated from the server.) which is auto-saved and reloaded to `localStorage` in the client (simple to disable if you don't need it.)
17
17
-[Emotion](https://emotion.sh/) CSS-in-JS, with inline `<style>` tag generation that contains only the CSS that needs to be rendered.
18
18
-[Sass](https://sass-lang.com/), [Less](http://lesscss.org/) and [PostCSS](https://postcss.org/) when importing `.css/.scss/.less` files.
19
19
-[React Router 4](https://reacttraining.com/react-router/) for declarative browser + server routes.
20
-
20
+
-[GraphQL Code Generator](https://graphql-code-generator.com/) for parsing remote GraphQL server schemas, for automatically building fully-typed Apollo React HOCs instead of writing `<Query>` / `<Mutation>` queries manually
21
21
- Declarative/dynamic `<head>` section, using [react-helmet](https://github.com/nfl/react-helmet).
22
22
23
23
### Server-side rendering
@@ -70,14 +70,45 @@ https://reactql.org
70
70
Grab and unpack the latest version, install all dependencies, and start a server:
71
71
72
72
```
73
-
wget -qO- https://github.com/leebenson/reactql/archive/4.2.0.tar.gz | tar xvz
74
-
cd reactql-4.2.0
73
+
wget -qO- https://github.com/leebenson/reactql/archive/4.2.1.tar.gz | tar xvz
74
+
cd reactql-4.2.1
75
75
npm i
76
76
npm start
77
77
```
78
78
79
79
Your development server is now running on [http://localhost:3000](http://localhost:3000)
80
80
81
+
## Building GraphQL HOCs
82
+
83
+
By default, your GraphQL schema lives in [schema/schema.graphql](schema/schema.graphql)
84
+
85
+
To create fully Typescript-typed Apollo React HOCs based on your schema, simply put the query in a `.graphql` anywhere inside the source folder, and run:
86
+
87
+
```
88
+
npm run gen:graphql
89
+
```
90
+
91
+
You can then import the query like we do in the [HackerNews demo component](src/components/example/hackernews.tsx):
To get access to the underlying `gql`-templated query (in case you need it for refetching, etc), in this case it'd be `GetHackerNewsTopStories.Document`.
107
+
108
+
See [GraphQL Code Generator](https://graphql-code-generator.com/) for more details on how it works.
109
+
110
+
You can also edit [codegen.yml](codegen.yml) in the root to point to a remote schema, or change the file location.
111
+
81
112
## Development mode
82
113
83
114
Development mode offers a few useful features:
@@ -203,10 +234,12 @@ Here's a quick run-through of each sub-folder and what you'll find in it:
203
234
204
235
You'll also find some other useful goodies in the [root]()...
205
236
206
-
-[.env](.env) - Change your `GRAPHQL` server endpoint, and `WS_SUBSCRIPTIONS=1` for built-in WebSocket support.
237
+
- [.env](.env) - Change your `GRAPHQL` server endpoint, `WS_SUBSCRIPTIONS=1` for built-in WebSocket support, `HOST` if you want to bind the server to something other than localhost, and `LOCAL_STORAGE_KEY` to set the root key for saving MobX state locally in the client for automatic re-loading in a later session.
207
238
208
239
- [.nvmrc](.nvmrc) - Specify your preferred Node.js version, for use with NVM and used by many continuous deployment tools. Defaults to v11.8.0
209
240
241
+
- [codegen.yml](codegen.yml) - Settings for [GraphQL Code Generator](https://graphql-code-generator.com/) (which you can run with `npmrungen:graphql` to generate types/HOCs based on your GraphQL queries/mutations.)
242
+
210
243
- [netlify.toml](netlify.toml) - Build instructions for fast [Netlify](https://www.netlify.com/) deployments. **Tip: To quickly deploy a demo ReactQL app, [click here](https://app.netlify.com/start/deploy?repository=https://github.com/leebenson/reactql).**
211
244
212
245
- [types](types) - Some basic types that allow you to import fonts, images, CSS/SASS/LESS files, and allow use of the global `SERVER` boolean in your IDE.
0 commit comments