3
3
[](https://travis-ci.org/2fd/graphdoc)
4
4

5
5

6
+ [](https://coveralls.io/github/2fd/graphdoc?branch=master)
6
8
7
- * [demos](#demos)
8
- * [install](#install)
9
- * [use](#use)
10
- * [plugin](#plugin)
11
- * [template](#template)
12
- * [contributors](#contributors)
9
+ - [demos](#demos)
10
+ - [install](#install)
11
+ - [use](#use)
12
+ - [plugin](#plugin)
13
+ - [template](#template)
14
+ - [contributors](#contributors)
13
15
14
16
## Demos
15
17
16
- * Facebook Test [Star Wars](https://2fd.github.io/graphdoc/star-wars)
17
- * [Github V4 API](https://2fd.github.io/graphdoc/github)
18
- * [Shopify API](https://2fd.github.io/graphdoc/shopify/)
19
- * [Pokemon GraphQL](https://2fd.github.io/graphdoc/pokemon)
18
+ - Facebook Test [Star Wars](https://2fd.github.io/graphdoc/star-wars)
19
+ - [Github V4 API](https://2fd.github.io/graphdoc/github)
20
+ - [Shopify API](https://2fd.github.io/graphdoc/shopify/)
21
+ - [Pokemon GraphQL](https://2fd.github.io/graphdoc/pokemon)
20
22
21
23
## Install
22
24
@@ -39,15 +41,15 @@ npm install -g @2fd/graphdoc
39
41
```
40
42
41
43
### Generate documentation from for the ["modularized
44
+
42
45
schema"](http://dev.apollodata.com/tools/graphql-tools/generate-schema.html#modularizing) of graphql-tools
43
46
44
47
```bash
45
48
> graphdoc -s ./schema.js -o ./doc/schema
46
49
```
47
50
48
51
> [`./schema.graphql`](https://github.com/2fd/graphdoc/blob/master/test/starwars.graphql) must be able to be interpreted
49
- with [graphql-js/utilities#buildSchema](http://graphql.org/graphql-js/utilities/#buildschema)
50
-
52
+ > with [graphql-js/utilities#buildSchema](http://graphql.org/graphql-js/utilities/#buildschema)
51
53
52
54
### Generate documentation from json file
53
55
@@ -56,20 +58,19 @@ with [graphql-js/utilities#buildSchema](http://graphql.org/graphql-js/utilities/
56
58
```
57
59
58
60
> `./schema.json` contains the result of [GraphQL introspection
59
- query](https://github.com/2fd/graphdoc/blob/gh-pages/introspection.graphql)
61
+ > query](https://github.com/2fd/graphdoc/blob/gh-pages/introspection.graphql)
60
62
61
63
### Puts the options in your `package.json`
62
64
63
65
```javascript
64
66
// package.json
65
67
66
68
{
67
- "name": "project",
68
- // [...]
69
- "graphdoc": {
70
- "endpoint": "http://localhost:8080/graphql",
71
- "output": "./doc/schema",
72
- }
69
+ "name": "project",
70
+ "graphdoc": {
71
+ "endpoint": "http://localhost:8080/graphql",
72
+ "output": "./doc/schema",
73
+ }
73
74
}
74
75
```
75
76
@@ -103,11 +104,11 @@ or a `constructor` and export it as `default`
103
104
If you export your plugin as a constructor, when going to be initialized,
104
105
will receive three parameters
105
106
106
- * `schema`: The full the result of [GraphQL introspection
107
- query](https://github.com/2fd/graphdoc/blob/gh-pages/introspection.graphql)
108
- * `projectPackage`: The content of `package.json` of current project (or the content of file defined with `--config`
109
- flag).
110
- * `graphdocPackage`: The content of `package.json` of graphdoc.
107
+ - `schema`: The full the result of [GraphQL introspection
108
+ query](https://github.com/2fd/graphdoc/blob/gh-pages/introspection.graphql)
109
+ - `projectPackage`: The content of `package.json` of current project (or the content of file defined with `--config`
110
+ flag).
111
+ - `graphdocPackage`: The content of `package.json` of graphdoc.
111
112
112
113
> For performance reasons all plugins receive the reference to the same object
113
114
> and therefore should not modify them directly as it could affect the behavior
@@ -116,58 +117,58 @@ flag).
116
117
#### Examples
117
118
118
119
```typescript
119
-
120
120
// es2015 export constructor
121
121
export default class MyPlugin {
122
- constructor(schema, projectPackage, graphdocPackage){}
123
- getAssets() { /* ... */ }
124
- /* ... */
122
+ constructor(schema, projectPackage, graphdocPackage) {}
123
+ getAssets() {
124
+ /* ... */
125
+ }
125
126
}
126
-
127
127
```
128
128
129
129
```typescript
130
130
// es2015 export plain object
131
131
export default cost myPlugin = {
132
- getAssets() { /* ... */ },
133
- /* ... */
132
+ getAssets() {
133
+ /* ... */
134
+ },
134
135
}
135
136
```
136
137
137
138
```javascript
138
-
139
139
// export constructor
140
- function MyPlugin(schema, projectPackage, graphdocPackage) { /* ... */ }
140
+ function MyPlugin(schema, projectPackage, graphdocPackage) {
141
+ /* ... */
142
+ }
141
143
142
- MyPlugin.prototype.getAssets = function() { /* ... */ };
143
- /* ... */
144
+ MyPlugin.prototype.getAssets = function() {
145
+ /* ... */
146
+ };
144
147
145
148
exports.default = MyPlugin;
146
149
```
147
150
148
151
```javascript
149
-
150
152
// export plain object
151
153
152
154
exports.default = {
153
- getAssets: function() { /* ... */ },
154
- /* ... */
155
- }
156
-
155
+ getAssets: function() {
156
+ /* ... */
157
+ }
158
+ };
157
159
```
158
160
159
161
### Use plugin
160
162
161
163
You can use the plugins in 2 ways.
162
164
163
-
164
165
#### Use plugins with command line
165
166
166
167
```bash
167
168
> graphdoc -p graphdoc/plugins/default \
168
- -p some-dependencies/plugin \
169
- -p ./lib/plugin/my-own-plugin \
170
- -s ./schema.json -o ./doc/schema
169
+ -p some-dependencies/plugin \
170
+ -p ./lib/plugin/my-own-plugin \
171
+ -s ./schema.json -o ./doc/schema
171
172
```
172
173
173
174
#### Use plugins with `package.json`
@@ -176,17 +177,16 @@ You can use the plugins in 2 ways.
176
177
// package.json
177
178
178
179
{
179
- "name": "project",
180
- // [...]
181
- "graphdoc": {
182
- "endpoint": "http://localhost:8080/graphql",
183
- "output": "./doc/schema",
184
- "plugins": [
185
- "graphdoc/plugins/default",
186
- "some-dependencie/plugin",
187
- "./lib/plugin/my-own-plugin"
188
- ]
189
- }
180
+ "name": "project",
181
+ "graphdoc": {
182
+ "endpoint": "http://localhost:8080/graphql",
183
+ "output": "./doc/schema",
184
+ "plugins": [
185
+ "graphdoc/plugins/default",
186
+ "some-dependencie/plugin",
187
+ "./lib/plugin/my-own-plugin"
188
+ ]
189
+ }
190
190
}
191
191
```
192
192
@@ -198,9 +198,7 @@ You can use the plugins in 2 ways.
198
198
199
199
> TODO
200
200
201
-
202
201
## Contributors
203
202
204
- {{ #each contributors }}
205
- * [<img src =" {{{ avatar_url }}} " width =" 40" > {{{ login }}} ]({{{ html_url }}} )
206
- {{ /each }}
203
+ {{ #each contributors }} - [<img src =" {{{ avatar_url }}} " width =" 40" > {{{ login }}} ]({{{ html_url }}} )
204
+ {{ /each }}
0 commit comments