-
Notifications
You must be signed in to change notification settings - Fork 4
/
usage.md.hbs
35 lines (21 loc) · 1.17 KB
/
usage.md.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
### Usage
{{exec "node bin/graphql-typewriter.js --help"}}
`{{package.name}}` is assumed to be run in the root folder of a npm-project.
It finds all .graphqls files recursively and adds a .graphqls.ts file next each file
(excluding the `node_modules`-folder).
The source GraphQL-schema `example.graphqls` that looks like
{{include 'examples/graphql/schema/example.graphqls' 'graphql'}}
will be converted into the following `example.graphqls.types.ts`:
{{include 'examples/graphql/schema/example.graphqls.types.ts' 'ts'}}
Note that all the field (non-argument) types can either be
* the actual type (`Person`),
* a promise for the actual type (`Promise<Person>`),
* a function generating the actual type (`(): Person`), or
* a function generating a Promise (`(): Promise<Person>`)
For fields with arguments, only the latter two apply.
With this interface, you can write the following program (`example-usage.ts`):
{{include 'examples/example-usage.ts' }}
The program uses the interface to build an root-implementation that can be validate
by Typescript (Promise validation works with TypeScript 2.1 onwards).
The output of this program is
{{exec 'node example-usage' cwd='examples'}}