Repository navigation
Expand file tree
/
Copy pathgraphql-io.d.ts
More file actions
203 lines (181 loc) · 9.64 KB
/
Copy pathgraphql-io.d.ts
File metadata and controls
203 lines (181 loc) · 9.64 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
** GraphQL-IO -- GraphQL Network Communication Framework
** Copyright (c) 2016-2019 Dr. Ralf S. Engelschall <rse@engelschall.com>
**
** Permission is hereby granted, free of charge, to any person obtaining
** a copy of this software and associated documentation files (the
** "Software"), to deal in the Software without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Software, and to
** permit persons to whom the Software is furnished to do so, subject to
** the following conditions:
**
** The above copyright notice and this permission notice shall be included
** in all copies or substantial portions of the Software.
**
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/* The GraphQL-IO Server API consists of the primary class Server. */
declare module "graphql-io-server" {
/* The primary API class of GraphQL-IO Server,
representing the network communication server. */
class Server {
/* Construct a new GraphQL-IO Server instance. */
public constructor(options?: {
/* The base URL of the server.
Has to match the regex `^https?:\/\/.+?:\d+$`.
The default is `"http://127.0.0.1:8080"`. */
url: string
/* The URL path section. */
path: {
/* The relative URL path to the optional static frontend.
Has to match the regex `^\\/.*$`.
The default is `/`. */
frontend: string,
/* The relative URL path to the optional GraphiQL frontend.
Has to match the regex `^\\/.+$`.
The default is `/api`. */
graphiql: string,
/* The relative URL path to the login service of the server.
Has to match the regex `^\\/.+$`.
The default is `/api/auth/login`. */
login: string,
/* The relative URL path to the session service of the server.
Has to match the regex `^\\/.+$`.
The default is `/api/auth/session`. */
session: string,
/* The relative URL path to the logout service of the server.
Has to match the regex `^\\/.+$`.
The default is `/api/auth/logout`. */
logout: string,
/* The relative URL path to the GraphQL service of the server.
Has to match the regex `^\\/.+$`.
The default is `/api/data/graph`. */
graph: string,
/* The relative URL path to the BLOB service of the server.
Has to match the regex `^\\/.+$`.
The default is `/api/data/blob`. */
blob: string
}
/* The Transport Layer Security (TLS) section. */
tls: {
/* The TLS certificate file in PEM format. */
crt: string,
/* The TLS private key file in PEM format. */
key: string
},
/* The internal secret for JSON Web Token (JWT) generation.
The default is an auto-generated secret which changes on every service start. */
secret: string,
/* The optional path to a HTML5 SPA based User Interface (UI) frontend application
which should be statically served to the client under the base URL. */
frontend: string
/* The name of the GraphQL root-level element (default: Root) */
root: string
/* The frame encoding for the GraphQL over WebSocket communication.
Has to be either `cbor` (maximum performance, binary),
`msgpack` (maximum performance, binary) or `json` (less performance, text, human readable).
The default is `cbor`. */
encoding: string
/* The debugging level.
Has to be an integer between 0 (no debugging) and 3 (maximum debugging messages).
The default is 0. The debugging messages are emitted as the event `debug`
and can be received with `client.on("debug", (msg) => { ... })`. */
debug: number
})
/* Listen to an event **eventName** and let the callback **handler** be asynchronously
called for every emitted event. Known events are `debug` (handler argument:
`info: { date: string, level: number, msg: string, log: string })`
and `error` (handler argument: `error: Error`). Returns a function
to remove the handler again. */
public on(eventName: string, handler: (eventData: any) => void): () => void
/* Latch into a hook **hookName** and let the callback **handler** be synchronously
called for every hook processing. Returns a function to remove the handler again.
Known hooks are:
- `server-configure`
(processing type: "promise", handler argument:
`server: GraphQLIOServer`)
- `jwt-validate`
(processing type: "pass", handler argument:
`ctx: { error: null, result: true }, decoded: Object, request: Object`)
- `server-start`
(processing type: "promise", handler argument:
`server: HAPIServer`)
- `server-stop`
(processing type: "promise", handler argument:
`server: HAPIServer`)
- `peer-recognize`
(processing type: "promise", handler argument:
`ctx: { error: null, peerId: String }`)
- `account-authenticate`
(processing type: "promise", handler argument:
`ctx: { error: null, accountId: String, username: null, password: null }`)
- `session-create`
(processing type: "promise", handler argument:
`ctx: { error: null, sessionId: null, accountId: String, peerId: String, ttl: Number }`)
- `session-details`
(processing type: "promise", handler argument:
`ctx: { error: null, peerId: null|String, accounId: null|String, sessionId: null|String }`)
- `session-destroy`
(processing type: "promise", handler argument:
`ctx: { error: null, sessionId: String }`)
- `graphql-schema`
(processing type: "concat", handler argument: none)
- `graphql-resolver`
(processing type: "concat", handler argument: `resolver: Object`)
- `graphql-postproc-schema`
(processing type: "pass", handler argument: `schema: String`)
- `graphql-postproc-resolver`
(processing type: "pass", handler argument: `resolver: Object`)
- `graphql-postproc-schema-exec`
(processing type: "pass", handler argument: `schema: Object`)
- `client-connect`
(processing type: "promise", handler argument:
`ctx: { ctx: Object, ws: Object, wsf: Object, req: Object, peer: String }`)
- `client-disconnect`
(processing type: "promise", handler argument:
`ctx: { ctx: Object, ws: Object, req: Object, peer: String }`)
- `client-request`
(processing type: "promise", handler argument:
`ctx: { request: Object, ws: Object }`)
- `graphql-transaction`
(processing type: "pass", handler argument:
`ctx: { schema: Object, query: String, variables: Object,
operation: String, ctx: Object }`)
- `graphql-query`
(processing type: "promise", handler argument:
`ctx: { schema: Object, query: String, variables: Object,
operation: String, ctx: Object }`)
- `graphql-response-success`
(processing type: "pass", handler argument: `result: Object`)
- `graphql-response-error`
(processing type: "pass", handler argument: `result: Object`)
- `graphql-result`
(processing type: "promise", handler argument:
`ctx: { schema: Object, query: String, variables: Object,
operation: String, result: Object }`)
- `blob`
(processing type: "promise", handler argument:
`ctx: { error: null, path: String, filename: null, type: null, content: null,
request: Object, peerId: String, accountId: String, sessionId: String }`) */
public at(hookName: string, handler: (...args: any[]) => any): () => void
/* Merge one or more options into the Server configuration.
This accepts the same **options** as the constructor.
Should be used before any call to connect(). */
public set(options: object): Server
/* Initiate a start of the server.
This instanciates the internal network connections. */
public start(): Promise<Server>
/* Initiate a stop of the server.
This drops the internal network connections. */
public stop(): Promise<Server>
}
const server: Server
export = server
}