sofa-api 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ast.d.ts +1 -1
- package/index.d.ts +1 -1
- package/index.js +43 -36
- package/index.mjs +29 -22
- package/package.json +6 -7
- package/router.d.ts +4 -5
- package/subscriptions.d.ts +2 -2
- package/types.d.ts +7 -7
package/ast.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SofaConfig } from './sofa';
|
|
2
2
|
export { OpenAPI } from './open-api';
|
|
3
|
-
export declare function useSofa(config: SofaConfig): import("@whatwg-node/
|
|
3
|
+
export declare function useSofa(config: SofaConfig): import("@whatwg-node/router").Router<import("./types").DefaultSofaServerContext>;
|
package/index.js
CHANGED
|
@@ -6,12 +6,11 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
|
|
|
6
6
|
|
|
7
7
|
const tslib = require('tslib');
|
|
8
8
|
const graphql = require('graphql');
|
|
9
|
-
const ittyRouter = require('itty-router');
|
|
10
9
|
const utils = require('@graphql-tools/utils');
|
|
11
10
|
const paramCase = require('param-case');
|
|
12
11
|
const fetch = require('@whatwg-node/fetch');
|
|
13
12
|
const colors = _interopDefault(require('ansi-colors'));
|
|
14
|
-
const
|
|
13
|
+
const router = require('@whatwg-node/router');
|
|
15
14
|
const titleCase = require('title-case');
|
|
16
15
|
|
|
17
16
|
function getOperationInfo(doc) {
|
|
@@ -49,8 +48,7 @@ function resolveVariable({ value, type, schema, }) {
|
|
|
49
48
|
if (graphql.isScalarType(namedType)) {
|
|
50
49
|
// GraphQLBoolean.serialize expects a boolean or a number only
|
|
51
50
|
if (graphql.isEqualType(graphql.GraphQLBoolean, namedType)) {
|
|
52
|
-
|
|
53
|
-
value = value === 'true';
|
|
51
|
+
value = (value === 'true' || value === true);
|
|
54
52
|
}
|
|
55
53
|
return namedType.serialize(value);
|
|
56
54
|
}
|
|
@@ -193,20 +191,27 @@ class SubscriptionManager {
|
|
|
193
191
|
});
|
|
194
192
|
// success
|
|
195
193
|
(() => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
196
|
-
var e_1,
|
|
194
|
+
var _a, e_1, _b, _c;
|
|
197
195
|
try {
|
|
198
|
-
for (var execution_1 = tslib.__asyncValues(execution), execution_1_1; execution_1_1 = yield execution_1.next(),
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
result
|
|
203
|
-
|
|
196
|
+
for (var _d = true, execution_1 = tslib.__asyncValues(execution), execution_1_1; execution_1_1 = yield execution_1.next(), _a = execution_1_1.done, !_a;) {
|
|
197
|
+
_c = execution_1_1.value;
|
|
198
|
+
_d = false;
|
|
199
|
+
try {
|
|
200
|
+
const result = _c;
|
|
201
|
+
yield this.sendData({
|
|
202
|
+
id,
|
|
203
|
+
result,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
_d = true;
|
|
208
|
+
}
|
|
204
209
|
}
|
|
205
210
|
}
|
|
206
211
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
207
212
|
finally {
|
|
208
213
|
try {
|
|
209
|
-
if (
|
|
214
|
+
if (!_d && !_a && (_b = execution_1.return)) yield _b.call(execution_1);
|
|
210
215
|
}
|
|
211
216
|
finally { if (e_1) throw e_1.error; }
|
|
212
217
|
}
|
|
@@ -272,7 +277,7 @@ class SubscriptionManager {
|
|
|
272
277
|
|
|
273
278
|
function createRouter(sofa) {
|
|
274
279
|
logger.debug('[Sofa] Creating router');
|
|
275
|
-
const router =
|
|
280
|
+
const router$1 = router.createRouter({
|
|
276
281
|
base: sofa.basePath,
|
|
277
282
|
});
|
|
278
283
|
const queryType = sofa.schema.getQueryType();
|
|
@@ -280,7 +285,7 @@ function createRouter(sofa) {
|
|
|
280
285
|
const subscriptionManager = new SubscriptionManager(sofa);
|
|
281
286
|
if (queryType) {
|
|
282
287
|
Object.keys(queryType.getFields()).forEach((fieldName) => {
|
|
283
|
-
const route = createQueryRoute({ sofa, router, fieldName });
|
|
288
|
+
const route = createQueryRoute({ sofa, router: router$1, fieldName });
|
|
284
289
|
if (sofa.onRoute) {
|
|
285
290
|
sofa.onRoute(route);
|
|
286
291
|
}
|
|
@@ -288,13 +293,13 @@ function createRouter(sofa) {
|
|
|
288
293
|
}
|
|
289
294
|
if (mutationType) {
|
|
290
295
|
Object.keys(mutationType.getFields()).forEach((fieldName) => {
|
|
291
|
-
const route = createMutationRoute({ sofa, router, fieldName });
|
|
296
|
+
const route = createMutationRoute({ sofa, router: router$1, fieldName });
|
|
292
297
|
if (sofa.onRoute) {
|
|
293
298
|
sofa.onRoute(route);
|
|
294
299
|
}
|
|
295
300
|
});
|
|
296
301
|
}
|
|
297
|
-
router.post('/webhook', (request, serverContext) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
302
|
+
router$1.post('/webhook', (request, serverContext) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
298
303
|
const { subscription, variables, url } = yield request.json();
|
|
299
304
|
try {
|
|
300
305
|
const result = yield subscriptionManager.start({
|
|
@@ -302,7 +307,7 @@ function createRouter(sofa) {
|
|
|
302
307
|
variables,
|
|
303
308
|
url,
|
|
304
309
|
}, Object.assign(Object.assign({}, serverContext), { request }));
|
|
305
|
-
return new
|
|
310
|
+
return new router.Response(JSON.stringify(result), {
|
|
306
311
|
status: 200,
|
|
307
312
|
statusText: 'OK',
|
|
308
313
|
headers: {
|
|
@@ -311,13 +316,13 @@ function createRouter(sofa) {
|
|
|
311
316
|
});
|
|
312
317
|
}
|
|
313
318
|
catch (error) {
|
|
314
|
-
return new
|
|
319
|
+
return new router.Response(JSON.stringify(error), {
|
|
315
320
|
status: 500,
|
|
316
321
|
statusText: 'Subscription failed',
|
|
317
322
|
});
|
|
318
323
|
}
|
|
319
324
|
}));
|
|
320
|
-
router.post('/webhook/:id', (request, serverContext) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
325
|
+
router$1.post('/webhook/:id', (request, serverContext) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
321
326
|
var _a;
|
|
322
327
|
const id = (_a = request.params) === null || _a === void 0 ? void 0 : _a.id;
|
|
323
328
|
const body = yield request.json();
|
|
@@ -329,7 +334,7 @@ function createRouter(sofa) {
|
|
|
329
334
|
id,
|
|
330
335
|
variables,
|
|
331
336
|
}, contextValue);
|
|
332
|
-
return new
|
|
337
|
+
return new router.Response(JSON.stringify(result), {
|
|
333
338
|
status: 200,
|
|
334
339
|
statusText: 'OK',
|
|
335
340
|
headers: {
|
|
@@ -338,18 +343,18 @@ function createRouter(sofa) {
|
|
|
338
343
|
});
|
|
339
344
|
}
|
|
340
345
|
catch (error) {
|
|
341
|
-
return new
|
|
346
|
+
return new router.Response(JSON.stringify(error), {
|
|
342
347
|
status: 500,
|
|
343
348
|
statusText: 'Subscription failed to update',
|
|
344
349
|
});
|
|
345
350
|
}
|
|
346
351
|
}));
|
|
347
|
-
router.delete('/webhook/:id', (request) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
352
|
+
router$1.delete('/webhook/:id', (request) => tslib.__awaiter(this, void 0, void 0, function* () {
|
|
348
353
|
var _b;
|
|
349
354
|
const id = (_b = request.params) === null || _b === void 0 ? void 0 : _b.id;
|
|
350
355
|
try {
|
|
351
356
|
const result = yield subscriptionManager.stop(id);
|
|
352
|
-
return new
|
|
357
|
+
return new router.Response(JSON.stringify(result), {
|
|
353
358
|
status: 200,
|
|
354
359
|
statusText: 'OK',
|
|
355
360
|
headers: {
|
|
@@ -358,13 +363,13 @@ function createRouter(sofa) {
|
|
|
358
363
|
});
|
|
359
364
|
}
|
|
360
365
|
catch (error) {
|
|
361
|
-
return new
|
|
366
|
+
return new router.Response(JSON.stringify(error), {
|
|
362
367
|
status: 500,
|
|
363
368
|
statusText: 'Subscription failed to stop',
|
|
364
369
|
});
|
|
365
370
|
}
|
|
366
371
|
}));
|
|
367
|
-
return router;
|
|
372
|
+
return router$1;
|
|
368
373
|
}
|
|
369
374
|
function createQueryRoute({ sofa, router, fieldName, }) {
|
|
370
375
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -395,7 +400,8 @@ function createQueryRoute({ sofa, router, fieldName, }) {
|
|
|
395
400
|
path: (_c = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.path) !== null && _c !== void 0 ? _c : getPath(fieldName, isSingle && hasIdArgument),
|
|
396
401
|
responseStatus: (_d = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.responseStatus) !== null && _d !== void 0 ? _d : 200,
|
|
397
402
|
};
|
|
398
|
-
|
|
403
|
+
const routerMethod = route.method.toLowerCase();
|
|
404
|
+
router[routerMethod](route.path, useHandler({ info, route, fieldName, sofa, operation }));
|
|
399
405
|
logger.debug(`[Router] ${fieldName} query available at ${route.method} ${route.path}`);
|
|
400
406
|
return {
|
|
401
407
|
document: operation,
|
|
@@ -431,7 +437,8 @@ function createMutationRoute({ sofa, router, fieldName, }) {
|
|
|
431
437
|
responseStatus: (_d = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.responseStatus) !== null && _d !== void 0 ? _d : 200,
|
|
432
438
|
};
|
|
433
439
|
const { method, path } = route;
|
|
434
|
-
|
|
440
|
+
const routerKey = method.toLowerCase();
|
|
441
|
+
router[routerKey](path, useHandler({ info, route, fieldName, sofa, operation }));
|
|
435
442
|
logger.debug(`[Router] ${fieldName} mutation available at ${method} ${path}`);
|
|
436
443
|
return {
|
|
437
444
|
document: operation,
|
|
@@ -501,12 +508,12 @@ function useHandler(config) {
|
|
|
501
508
|
status = 500;
|
|
502
509
|
}
|
|
503
510
|
if (errors.length === 1) {
|
|
504
|
-
return new
|
|
511
|
+
return new router.Response(JSON.stringify(errors[0]), {
|
|
505
512
|
status,
|
|
506
513
|
headers,
|
|
507
514
|
});
|
|
508
515
|
}
|
|
509
|
-
return new
|
|
516
|
+
return new router.Response(JSON.stringify({ errors }), {
|
|
510
517
|
status,
|
|
511
518
|
headers,
|
|
512
519
|
});
|
|
@@ -514,7 +521,7 @@ function useHandler(config) {
|
|
|
514
521
|
const errorHandler = sofa.errorHandler || defaultErrorHandler;
|
|
515
522
|
return errorHandler(result.errors);
|
|
516
523
|
}
|
|
517
|
-
return new
|
|
524
|
+
return new router.Response(JSON.stringify((_a = result.data) === null || _a === void 0 ? void 0 : _a[fieldName]), {
|
|
518
525
|
status: config.route.responseStatus,
|
|
519
526
|
headers: {
|
|
520
527
|
'Content-Type': 'application/json',
|
|
@@ -686,12 +693,12 @@ function resolveFieldType(type, opts) {
|
|
|
686
693
|
};
|
|
687
694
|
}
|
|
688
695
|
if (graphql.isScalarType(type)) {
|
|
689
|
-
|
|
696
|
+
const resolved = mapToPrimitive(type.name) ||
|
|
690
697
|
opts.customScalars[type.name] ||
|
|
691
|
-
((_a = type.extensions) === null || _a === void 0 ? void 0 : _a.jsonSchema)
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
698
|
+
((_a = type.extensions) === null || _a === void 0 ? void 0 : _a.jsonSchema) || {
|
|
699
|
+
type: 'object',
|
|
700
|
+
};
|
|
701
|
+
return Object.assign({}, resolved);
|
|
695
702
|
}
|
|
696
703
|
if (graphql.isEnumType(type)) {
|
|
697
704
|
return {
|
|
@@ -880,7 +887,7 @@ function OpenAPI({ schema, info, servers, components, security, tags, customScal
|
|
|
880
887
|
}
|
|
881
888
|
|
|
882
889
|
function useSofa(config) {
|
|
883
|
-
return
|
|
890
|
+
return createRouter(createSofa(config));
|
|
884
891
|
}
|
|
885
892
|
|
|
886
893
|
exports.OpenAPI = OpenAPI;
|
package/index.mjs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { __awaiter, __asyncValues } from 'tslib';
|
|
2
2
|
import { getOperationAST, Kind, isScalarType, isEqualType, GraphQLBoolean, isInputObjectType, isObjectType, isNonNullType, execute, subscribe, getNamedType, isListType, isEnumType, parse, printType, isIntrospectionType } from 'graphql';
|
|
3
|
-
import { Router } from 'itty-router';
|
|
4
3
|
import { buildOperationNodeForField } from '@graphql-tools/utils';
|
|
5
4
|
import { paramCase } from 'param-case';
|
|
6
|
-
import { crypto, fetch
|
|
5
|
+
import { crypto, fetch } from '@whatwg-node/fetch';
|
|
7
6
|
import colors from 'ansi-colors';
|
|
8
|
-
import {
|
|
7
|
+
import { createRouter as createRouter$1, Response } from '@whatwg-node/router';
|
|
9
8
|
import { titleCase } from 'title-case';
|
|
10
9
|
|
|
11
10
|
function getOperationInfo(doc) {
|
|
@@ -43,8 +42,7 @@ function resolveVariable({ value, type, schema, }) {
|
|
|
43
42
|
if (isScalarType(namedType)) {
|
|
44
43
|
// GraphQLBoolean.serialize expects a boolean or a number only
|
|
45
44
|
if (isEqualType(GraphQLBoolean, namedType)) {
|
|
46
|
-
|
|
47
|
-
value = value === 'true';
|
|
45
|
+
value = (value === 'true' || value === true);
|
|
48
46
|
}
|
|
49
47
|
return namedType.serialize(value);
|
|
50
48
|
}
|
|
@@ -187,20 +185,27 @@ class SubscriptionManager {
|
|
|
187
185
|
});
|
|
188
186
|
// success
|
|
189
187
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
190
|
-
var e_1,
|
|
188
|
+
var _a, e_1, _b, _c;
|
|
191
189
|
try {
|
|
192
|
-
for (var execution_1 = __asyncValues(execution), execution_1_1; execution_1_1 = yield execution_1.next(),
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
result
|
|
197
|
-
|
|
190
|
+
for (var _d = true, execution_1 = __asyncValues(execution), execution_1_1; execution_1_1 = yield execution_1.next(), _a = execution_1_1.done, !_a;) {
|
|
191
|
+
_c = execution_1_1.value;
|
|
192
|
+
_d = false;
|
|
193
|
+
try {
|
|
194
|
+
const result = _c;
|
|
195
|
+
yield this.sendData({
|
|
196
|
+
id,
|
|
197
|
+
result,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
_d = true;
|
|
202
|
+
}
|
|
198
203
|
}
|
|
199
204
|
}
|
|
200
205
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
201
206
|
finally {
|
|
202
207
|
try {
|
|
203
|
-
if (
|
|
208
|
+
if (!_d && !_a && (_b = execution_1.return)) yield _b.call(execution_1);
|
|
204
209
|
}
|
|
205
210
|
finally { if (e_1) throw e_1.error; }
|
|
206
211
|
}
|
|
@@ -266,7 +271,7 @@ class SubscriptionManager {
|
|
|
266
271
|
|
|
267
272
|
function createRouter(sofa) {
|
|
268
273
|
logger.debug('[Sofa] Creating router');
|
|
269
|
-
const router =
|
|
274
|
+
const router = createRouter$1({
|
|
270
275
|
base: sofa.basePath,
|
|
271
276
|
});
|
|
272
277
|
const queryType = sofa.schema.getQueryType();
|
|
@@ -389,7 +394,8 @@ function createQueryRoute({ sofa, router, fieldName, }) {
|
|
|
389
394
|
path: (_c = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.path) !== null && _c !== void 0 ? _c : getPath(fieldName, isSingle && hasIdArgument),
|
|
390
395
|
responseStatus: (_d = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.responseStatus) !== null && _d !== void 0 ? _d : 200,
|
|
391
396
|
};
|
|
392
|
-
|
|
397
|
+
const routerMethod = route.method.toLowerCase();
|
|
398
|
+
router[routerMethod](route.path, useHandler({ info, route, fieldName, sofa, operation }));
|
|
393
399
|
logger.debug(`[Router] ${fieldName} query available at ${route.method} ${route.path}`);
|
|
394
400
|
return {
|
|
395
401
|
document: operation,
|
|
@@ -425,7 +431,8 @@ function createMutationRoute({ sofa, router, fieldName, }) {
|
|
|
425
431
|
responseStatus: (_d = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.responseStatus) !== null && _d !== void 0 ? _d : 200,
|
|
426
432
|
};
|
|
427
433
|
const { method, path } = route;
|
|
428
|
-
|
|
434
|
+
const routerKey = method.toLowerCase();
|
|
435
|
+
router[routerKey](path, useHandler({ info, route, fieldName, sofa, operation }));
|
|
429
436
|
logger.debug(`[Router] ${fieldName} mutation available at ${method} ${path}`);
|
|
430
437
|
return {
|
|
431
438
|
document: operation,
|
|
@@ -680,12 +687,12 @@ function resolveFieldType(type, opts) {
|
|
|
680
687
|
};
|
|
681
688
|
}
|
|
682
689
|
if (isScalarType(type)) {
|
|
683
|
-
|
|
690
|
+
const resolved = mapToPrimitive(type.name) ||
|
|
684
691
|
opts.customScalars[type.name] ||
|
|
685
|
-
((_a = type.extensions) === null || _a === void 0 ? void 0 : _a.jsonSchema)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
692
|
+
((_a = type.extensions) === null || _a === void 0 ? void 0 : _a.jsonSchema) || {
|
|
693
|
+
type: 'object',
|
|
694
|
+
};
|
|
695
|
+
return Object.assign({}, resolved);
|
|
689
696
|
}
|
|
690
697
|
if (isEnumType(type)) {
|
|
691
698
|
return {
|
|
@@ -874,7 +881,7 @@ function OpenAPI({ schema, info, servers, components, security, tags, customScal
|
|
|
874
881
|
}
|
|
875
882
|
|
|
876
883
|
function useSofa(config) {
|
|
877
|
-
return
|
|
884
|
+
return createRouter(createSofa(config));
|
|
878
885
|
}
|
|
879
886
|
|
|
880
887
|
export { OpenAPI, useSofa };
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sofa-api",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.2",
|
|
4
4
|
"description": "Create REST APIs with GraphQL",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^0.13.2 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/utils": "
|
|
11
|
-
"@whatwg-node/fetch": "^0.
|
|
12
|
-
"@whatwg-node/
|
|
10
|
+
"@graphql-tools/utils": "9.1.3",
|
|
11
|
+
"@whatwg-node/fetch": "^0.6.0",
|
|
12
|
+
"@whatwg-node/router": "^0.1.2",
|
|
13
13
|
"ansi-colors": "4.1.3",
|
|
14
|
-
"
|
|
15
|
-
"openapi-types": "12.0.2",
|
|
14
|
+
"openapi-types": "12.1.0",
|
|
16
15
|
"param-case": "3.0.4",
|
|
17
16
|
"title-case": "3.0.3",
|
|
18
|
-
"tslib": "2.4.
|
|
17
|
+
"tslib": "2.4.1"
|
|
19
18
|
},
|
|
20
19
|
"repository": {
|
|
21
20
|
"type": "git",
|
package/router.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Request as IttyRequest, Router } from 'itty-router';
|
|
2
1
|
import type { Sofa } from './sofa';
|
|
3
|
-
|
|
2
|
+
import type { DefaultSofaServerContext } from './types';
|
|
3
|
+
import { Router } from '@whatwg-node/router';
|
|
4
|
+
export type ErrorHandler = (errors: ReadonlyArray<any>) => Response;
|
|
4
5
|
declare module 'graphql' {
|
|
5
6
|
interface GraphQLHTTPErrorExtensions {
|
|
6
7
|
status?: number;
|
|
@@ -10,6 +11,4 @@ declare module 'graphql' {
|
|
|
10
11
|
http?: GraphQLHTTPErrorExtensions;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
declare
|
|
14
|
-
export declare function createRouter(sofa: Sofa): Router<SofaRequest, {}>;
|
|
15
|
-
export {};
|
|
14
|
+
export declare function createRouter(sofa: Sofa): Router<DefaultSofaServerContext>;
|
package/subscriptions.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ExecutionResult } from 'graphql';
|
|
2
2
|
import type { ContextValue } from './types';
|
|
3
3
|
import type { Sofa } from './sofa';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type ID = string;
|
|
5
|
+
export type SubscriptionFieldName = string;
|
|
6
6
|
export interface StartSubscriptionEvent {
|
|
7
7
|
subscription: SubscriptionFieldName;
|
|
8
8
|
variables: any;
|
package/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DefaultServerAdapterContext } from '@whatwg-node/
|
|
1
|
+
import { DefaultServerAdapterContext } from '@whatwg-node/router';
|
|
2
2
|
import { DocumentNode } from 'graphql';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export type ContextValue = Record<string, any>;
|
|
4
|
+
export type Ignore = string[];
|
|
5
|
+
export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
6
6
|
export interface RouteInfo {
|
|
7
7
|
document: DocumentNode;
|
|
8
8
|
path: string;
|
|
@@ -10,8 +10,8 @@ export interface RouteInfo {
|
|
|
10
10
|
tags?: string[];
|
|
11
11
|
description?: string;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
13
|
+
export type OnRoute = (info: RouteInfo) => void;
|
|
14
|
+
export type ContextFn = (serverContext: DefaultSofaServerContext) => Promise<ContextValue> | ContextValue;
|
|
15
|
+
export type DefaultSofaServerContext = DefaultServerAdapterContext & {
|
|
16
16
|
request: Request;
|
|
17
17
|
};
|