@graphql-yoga/nestjs 3.19.0 → 3.19.1-alpha-20251226143409-e80d60adf047757cd982b6dbeb9d745986781925
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/CHANGELOG.md +8 -0
- package/package.json +8 -8
- package/{__tests__ → tests}/graphql-ws.spec.ts +3 -1
- package/{__tests__ → tests}/subscriptions-transport-ws.spec.ts +3 -1
- package/LICENSE +0 -23
- package/dist/README.md +0 -64
- package/dist/cjs/index.js +0 -252
- package/dist/cjs/package.json +0 -1
- package/dist/esm/index.js +0 -248
- package/dist/package.json +0 -55
- package/dist/typings/index.d.cts +0 -51
- package/dist/typings/index.d.ts +0 -51
- /package/{__tests__ → tests}/fixtures/graphql/app.module.ts +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/cats-request-scoped.service.ts +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/cats.guard.ts +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/cats.module.ts +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/cats.resolvers.ts +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/cats.service.ts +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/cats.types.graphql +0 -0
- /package/{__tests__ → tests}/fixtures/graphql/cats/interfaces/cat.interface.ts +0 -0
- /package/{__tests__ → tests}/graphql-http.spec.ts +0 -0
- /package/{__tests__ → tests}/graphql.spec.ts +0 -0
- /package/{__tests__ → tests}/subscriptions.spec.ts +0 -0
- /package/{__tests__ → tests}/utils/pubsub.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @graphql-yoga/nestjs
|
|
2
2
|
|
|
3
|
+
## 3.19.1-alpha-20251226143409-e80d60adf047757cd982b6dbeb9d745986781925
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
[[`f8911bf`](https://github.com/graphql-hive/graphql-yoga/commit/f8911bff4be26fd85aaa505a8388b46420814b51)]:
|
|
9
|
+
- graphql-yoga@5.18.1-alpha-20251226143409-e80d60adf047757cd982b6dbeb9d745986781925
|
|
10
|
+
|
|
3
11
|
## 3.19.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-yoga/nestjs",
|
|
3
|
-
"version": "3.19.
|
|
3
|
+
"version": "3.19.1-alpha-20251226143409-e80d60adf047757cd982b6dbeb9d745986781925",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "GraphQL Yoga driver for NestJS GraphQL.",
|
|
6
6
|
"repository": {
|
|
@@ -41,12 +41,15 @@
|
|
|
41
41
|
"driver",
|
|
42
42
|
"graphql-yoga"
|
|
43
43
|
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"check": "tsc --pretty --noEmit"
|
|
46
|
+
},
|
|
44
47
|
"peerDependencies": {
|
|
45
48
|
"@nestjs/common": "^11.0.0",
|
|
46
49
|
"@nestjs/core": "^11.0.0",
|
|
47
50
|
"@nestjs/graphql": "^13.0.0",
|
|
48
51
|
"graphql": "^15.0.0 || ^16.0.0",
|
|
49
|
-
"graphql-yoga": "
|
|
52
|
+
"graphql-yoga": "workspace:^"
|
|
50
53
|
},
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@nestjs/common": "^11.0.0",
|
|
@@ -65,13 +68,13 @@
|
|
|
65
68
|
"graphql": "16.12.0",
|
|
66
69
|
"graphql-http": "^1.18.0",
|
|
67
70
|
"graphql-ws": "^6.0.0",
|
|
71
|
+
"graphql-yoga": "workspace:^",
|
|
68
72
|
"prettier": "^3.0.0",
|
|
69
73
|
"reflect-metadata": "^0.2.0",
|
|
70
74
|
"rxjs": "^7.8.0",
|
|
71
75
|
"subscriptions-transport-ws": "^0.11.0",
|
|
72
76
|
"tslib": "^2.8.1",
|
|
73
|
-
"ws": "^8.12.1"
|
|
74
|
-
"graphql-yoga": "^5.18.0"
|
|
77
|
+
"ws": "^8.12.1"
|
|
75
78
|
},
|
|
76
79
|
"publishConfig": {
|
|
77
80
|
"access": "public"
|
|
@@ -79,8 +82,5 @@
|
|
|
79
82
|
"sideEffects": false,
|
|
80
83
|
"typescript": {
|
|
81
84
|
"definition": "dist/typings/index.d.ts"
|
|
82
|
-
},
|
|
83
|
-
"scripts": {
|
|
84
|
-
"check": "tsc --pretty --noEmit"
|
|
85
85
|
}
|
|
86
|
-
}
|
|
86
|
+
}
|
|
@@ -21,7 +21,9 @@ beforeAll(async () => {
|
|
|
21
21
|
url = (await app.getUrl()) + '/graphql';
|
|
22
22
|
});
|
|
23
23
|
|
|
24
|
-
afterAll(() =>
|
|
24
|
+
afterAll(() => {
|
|
25
|
+
app.close();
|
|
26
|
+
});
|
|
25
27
|
|
|
26
28
|
it('should subscribe using subscriptions-transport-ws', async () => {
|
|
27
29
|
const client = new SubscriptionClient(
|
package/LICENSE
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018-2020 Graphcool
|
|
4
|
-
Copyright (c) 2020-2021 Prisma
|
|
5
|
-
Copyright (c) 2021- The Guild
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
SOFTWARE.
|
package/dist/README.md
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<br />
|
|
3
|
-
|
|
4
|
-
<h3>
|
|
5
|
-
<a href="https://the-guild.dev/graphql/yoga-server">GraphQL Yoga</a> plugin for <a href="https://nestjs.com">NestJS</a>
|
|
6
|
-
</h3>
|
|
7
|
-
|
|
8
|
-
<h6>Fully-featured GraphQL server as a plugin for the progressive Node.js framework.</h6>
|
|
9
|
-
|
|
10
|
-
<p>
|
|
11
|
-
Check out <a href="https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-nestjs">Yoga's documentation about NestJS integration</a>!
|
|
12
|
-
</p>
|
|
13
|
-
|
|
14
|
-
<br />
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
## Getting started
|
|
18
|
-
|
|
19
|
-
### Install
|
|
20
|
-
|
|
21
|
-
```shell
|
|
22
|
-
npm i @nestjs/graphql graphql-yoga graphql @graphql-yoga/nestjs
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
### Create application module
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
import { YogaDriver, YogaDriverConfig } from '@graphql-yoga/nestjs'
|
|
29
|
-
import { Module } from '@nestjs/common'
|
|
30
|
-
import { GraphQLModule } from '@nestjs/graphql'
|
|
31
|
-
|
|
32
|
-
@Module({
|
|
33
|
-
imports: [
|
|
34
|
-
GraphQLModule.forRoot<YogaDriverConfig>({
|
|
35
|
-
driver: YogaDriver
|
|
36
|
-
})
|
|
37
|
-
]
|
|
38
|
-
})
|
|
39
|
-
export class AppModule {}
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Develop GraphQL
|
|
43
|
-
|
|
44
|
-
This is just a HTTP transport driver; meaning, everything else should work as
|
|
45
|
-
[showcased in NestJS documentation](https://docs.nestjs.com/graphql/resolvers).
|
|
46
|
-
|
|
47
|
-
### Apollo Federation
|
|
48
|
-
|
|
49
|
-
Separately, we offer a [`@graphql-yoga/nestjs-federation` driver](/packages/nestjs-federation) which
|
|
50
|
-
allows building Apollo Federation Gateways and Services. Check it out!
|
|
51
|
-
|
|
52
|
-
## Contributing
|
|
53
|
-
|
|
54
|
-
If this is your first time contributing to this project, please do read our
|
|
55
|
-
[Contributor Workflow Guide](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md)
|
|
56
|
-
before you get started off.
|
|
57
|
-
|
|
58
|
-
Feel free to open issues, pull requests and create discussions. Community support is always welcome!
|
|
59
|
-
|
|
60
|
-
## Code of Conduct
|
|
61
|
-
|
|
62
|
-
Help us keep Yoga open and inclusive. Please read and follow our
|
|
63
|
-
[Code of Conduct](https://github.com/the-guild-org/Stack/blob/master/CODE_OF_CONDUCT.md) as adopted
|
|
64
|
-
from [Contributor Covenant](https://www.contributor-covenant.org/).
|
package/dist/cjs/index.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YogaDriver = exports.AbstractYogaDriver = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const graphql_1 = require("graphql");
|
|
6
|
-
const graphql_yoga_1 = require("graphql-yoga");
|
|
7
|
-
const common_1 = require("@nestjs/common");
|
|
8
|
-
const graphql_2 = require("@nestjs/graphql");
|
|
9
|
-
class AbstractYogaDriver extends graphql_2.AbstractGraphQLDriver {
|
|
10
|
-
yoga;
|
|
11
|
-
async start(options) {
|
|
12
|
-
const platformName = this.httpAdapterHost.httpAdapter.getType();
|
|
13
|
-
options = {
|
|
14
|
-
...options,
|
|
15
|
-
// disable error masking by default
|
|
16
|
-
maskedErrors: options.maskedErrors == null ? false : options.maskedErrors,
|
|
17
|
-
// disable graphiql in production
|
|
18
|
-
graphiql: options.graphiql == null ? process.env['NODE_ENV'] !== 'production' : options.graphiql,
|
|
19
|
-
};
|
|
20
|
-
if (platformName === 'express') {
|
|
21
|
-
return this.registerExpress(options);
|
|
22
|
-
}
|
|
23
|
-
if (platformName === 'fastify') {
|
|
24
|
-
return this.registerFastify(options);
|
|
25
|
-
}
|
|
26
|
-
throw new Error(`Provided HttpAdapter "${platformName}" not supported`);
|
|
27
|
-
}
|
|
28
|
-
async stop() {
|
|
29
|
-
// noop
|
|
30
|
-
}
|
|
31
|
-
registerExpress({ conditionalSchema, ...options }, { preStartHook } = {}) {
|
|
32
|
-
const app = this.httpAdapterHost.httpAdapter.getInstance();
|
|
33
|
-
preStartHook?.(app);
|
|
34
|
-
// nest's logger doesnt have the info method
|
|
35
|
-
class LoggerWithInfo extends common_1.Logger {
|
|
36
|
-
constructor(context) {
|
|
37
|
-
super(context);
|
|
38
|
-
}
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
info(message, ...args) {
|
|
41
|
-
this.log(message, ...args);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
const schema = this.mergeConditionalSchema(conditionalSchema, options.schema);
|
|
45
|
-
const yoga = (0, graphql_yoga_1.createYoga)({
|
|
46
|
-
...options,
|
|
47
|
-
schema,
|
|
48
|
-
graphqlEndpoint: options.path,
|
|
49
|
-
// disable logging by default
|
|
50
|
-
// however, if `true` use nest logger
|
|
51
|
-
logging: options.logging == null
|
|
52
|
-
? false
|
|
53
|
-
: options.logging
|
|
54
|
-
? new LoggerWithInfo('YogaDriver')
|
|
55
|
-
: options.logging,
|
|
56
|
-
});
|
|
57
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
58
|
-
// @ts-ignore - TODO: fix types
|
|
59
|
-
this.yoga = yoga;
|
|
60
|
-
app.use(yoga.graphqlEndpoint, (req, res) => yoga(req, res, { req, res }));
|
|
61
|
-
}
|
|
62
|
-
registerFastify({ conditionalSchema, ...options }, { preStartHook } = {}) {
|
|
63
|
-
const app = this.httpAdapterHost.httpAdapter.getInstance();
|
|
64
|
-
preStartHook?.(app);
|
|
65
|
-
const schema = this.mergeConditionalSchema(conditionalSchema, options.schema);
|
|
66
|
-
const yoga = (0, graphql_yoga_1.createYoga)({
|
|
67
|
-
...options,
|
|
68
|
-
schema,
|
|
69
|
-
graphqlEndpoint: options.path,
|
|
70
|
-
// disable logging by default
|
|
71
|
-
// however, if `true` use fastify logger
|
|
72
|
-
logging: options.logging == null ? false : options.logging ? app.log : options.logging,
|
|
73
|
-
});
|
|
74
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
|
-
// @ts-ignore - TODO: fix types
|
|
76
|
-
this.yoga = yoga;
|
|
77
|
-
app.all(yoga.graphqlEndpoint, async (req, reply) => {
|
|
78
|
-
const response = await yoga.handleNodeRequestAndResponse(req, reply, {
|
|
79
|
-
req,
|
|
80
|
-
reply,
|
|
81
|
-
});
|
|
82
|
-
for (const [key, value] of response.headers.entries())
|
|
83
|
-
reply.header(key, value);
|
|
84
|
-
reply.status(response.status);
|
|
85
|
-
reply.send(response.body);
|
|
86
|
-
return reply;
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
mergeConditionalSchema(conditionalSchema, schema) {
|
|
90
|
-
let mergedSchema = schema;
|
|
91
|
-
if (conditionalSchema) {
|
|
92
|
-
mergedSchema = async (request) => {
|
|
93
|
-
const schemas = [];
|
|
94
|
-
if (schema) {
|
|
95
|
-
schemas.push(schema);
|
|
96
|
-
}
|
|
97
|
-
const conditionalSchemaResult = typeof conditionalSchema === 'function'
|
|
98
|
-
? await conditionalSchema(request)
|
|
99
|
-
: await conditionalSchema;
|
|
100
|
-
if (conditionalSchemaResult) {
|
|
101
|
-
schemas.push(conditionalSchemaResult);
|
|
102
|
-
}
|
|
103
|
-
return (0, graphql_yoga_1.mergeSchemas)({
|
|
104
|
-
schemas,
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
return mergedSchema;
|
|
109
|
-
}
|
|
110
|
-
subscriptionWithFilter(instanceRef, filterFn,
|
|
111
|
-
// disable next error, the original function in @nestjs/graphql is also untyped
|
|
112
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
113
|
-
createSubscribeContext) {
|
|
114
|
-
return async (...args) => {
|
|
115
|
-
return (0, graphql_yoga_1.pipe)(await createSubscribeContext()(...args), (0, graphql_yoga_1.filter)((payload) =>
|
|
116
|
-
// typecast the spread sliced args to avoid error TS 2556, see https://github.com/microsoft/TypeScript/issues/49802
|
|
117
|
-
filterFn.call(instanceRef, payload, ...args.slice(1))));
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.AbstractYogaDriver = AbstractYogaDriver;
|
|
122
|
-
let YogaDriver = class YogaDriver extends AbstractYogaDriver {
|
|
123
|
-
subscriptionService;
|
|
124
|
-
async start(options) {
|
|
125
|
-
if (options.definitions?.path) {
|
|
126
|
-
if (!options.schema) {
|
|
127
|
-
throw new Error('Schema is required when generating definitions');
|
|
128
|
-
}
|
|
129
|
-
await this.graphQlFactory.generateDefinitions((0, graphql_1.printSchema)(options.schema), options);
|
|
130
|
-
}
|
|
131
|
-
await super.start(options);
|
|
132
|
-
if (options.subscriptions) {
|
|
133
|
-
if (!options.schema) {
|
|
134
|
-
throw new Error('Schema is required when using subscriptions');
|
|
135
|
-
}
|
|
136
|
-
const config = options.subscriptions === true
|
|
137
|
-
? {
|
|
138
|
-
'graphql-ws': true,
|
|
139
|
-
}
|
|
140
|
-
: options.subscriptions;
|
|
141
|
-
if (config['graphql-ws']) {
|
|
142
|
-
config['graphql-ws'] = typeof config['graphql-ws'] === 'object' ? config['graphql-ws'] : {};
|
|
143
|
-
if (options.conditionalSchema) {
|
|
144
|
-
throw new Error(`
|
|
145
|
-
Conditional schema is not supported with graphql-ws.
|
|
146
|
-
`);
|
|
147
|
-
}
|
|
148
|
-
config['graphql-ws'].onSubscribe = async (ctx, _id, params) => {
|
|
149
|
-
const { schema, execute, subscribe, contextFactory, parse, validate } = this.yoga.getEnveloped({
|
|
150
|
-
...ctx,
|
|
151
|
-
// @ts-expect-error context extra is from graphql-ws/lib/use/ws
|
|
152
|
-
req: ctx.extra.request,
|
|
153
|
-
// @ts-expect-error context extra is from graphql-ws/lib/use/ws
|
|
154
|
-
socket: ctx.extra.socket,
|
|
155
|
-
params,
|
|
156
|
-
});
|
|
157
|
-
const args = {
|
|
158
|
-
schema,
|
|
159
|
-
operationName: params.operationName,
|
|
160
|
-
document: parse(params.query),
|
|
161
|
-
variableValues: params.variables,
|
|
162
|
-
contextValue: await contextFactory({ execute, subscribe }),
|
|
163
|
-
};
|
|
164
|
-
const errors = validate(args.schema, args.document);
|
|
165
|
-
if (errors.length)
|
|
166
|
-
return errors;
|
|
167
|
-
return args;
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
if (config['subscriptions-transport-ws']) {
|
|
171
|
-
config['subscriptions-transport-ws'] =
|
|
172
|
-
typeof config['subscriptions-transport-ws'] === 'object'
|
|
173
|
-
? config['subscriptions-transport-ws']
|
|
174
|
-
: {};
|
|
175
|
-
if (options.conditionalSchema) {
|
|
176
|
-
throw new Error(`
|
|
177
|
-
Conditional schema is not supported with subscriptions-transport-ws.
|
|
178
|
-
`);
|
|
179
|
-
}
|
|
180
|
-
config['subscriptions-transport-ws'].onOperation = async (_msg, params, ws) => {
|
|
181
|
-
const { schema, execute, subscribe, contextFactory, parse, validate } = this.yoga.getEnveloped({
|
|
182
|
-
...params.context,
|
|
183
|
-
req:
|
|
184
|
-
// @ts-expect-error upgradeReq does exist but is untyped
|
|
185
|
-
ws.upgradeReq,
|
|
186
|
-
socket: ws,
|
|
187
|
-
params,
|
|
188
|
-
});
|
|
189
|
-
const args = {
|
|
190
|
-
schema,
|
|
191
|
-
operationName: params.operationName,
|
|
192
|
-
document: typeof params.query === 'string' ? parse(params.query) : params.query,
|
|
193
|
-
variables: params.variables,
|
|
194
|
-
context: await contextFactory({ execute, subscribe }),
|
|
195
|
-
};
|
|
196
|
-
const errors = validate(args.schema, args.document);
|
|
197
|
-
if (errors.length)
|
|
198
|
-
return errors;
|
|
199
|
-
return args;
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
this.subscriptionService = new graphql_2.GqlSubscriptionService({
|
|
203
|
-
schema: options.schema,
|
|
204
|
-
path: options.path,
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
206
|
-
// @ts-ignore
|
|
207
|
-
execute: (...args) => {
|
|
208
|
-
const contextValue =
|
|
209
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
210
|
-
// @ts-ignore
|
|
211
|
-
args[0].contextValue ||
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
args[3];
|
|
215
|
-
if (!contextValue) {
|
|
216
|
-
throw new Error('Execution arguments are missing the context value');
|
|
217
|
-
}
|
|
218
|
-
return (contextValue
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
220
|
-
// @ts-ignore
|
|
221
|
-
.execute(...args));
|
|
222
|
-
},
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
subscribe: (...args) => {
|
|
226
|
-
const contextValue =
|
|
227
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
228
|
-
// @ts-ignore
|
|
229
|
-
args[0].contextValue ||
|
|
230
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
231
|
-
// @ts-ignore
|
|
232
|
-
args?.[3];
|
|
233
|
-
if (!contextValue) {
|
|
234
|
-
throw new Error('Subscribe arguments are missing the context value');
|
|
235
|
-
}
|
|
236
|
-
return (contextValue
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
238
|
-
// @ts-ignore
|
|
239
|
-
.subscribe(...args));
|
|
240
|
-
},
|
|
241
|
-
...config,
|
|
242
|
-
}, this.httpAdapterHost.httpAdapter.getHttpServer());
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
async stop() {
|
|
246
|
-
await this.subscriptionService?.stop();
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
exports.YogaDriver = YogaDriver;
|
|
250
|
-
exports.YogaDriver = YogaDriver = tslib_1.__decorate([
|
|
251
|
-
(0, common_1.Injectable)()
|
|
252
|
-
], YogaDriver);
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
package/dist/esm/index.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { printSchema } from 'graphql';
|
|
3
|
-
import { createYoga, filter, mergeSchemas, pipe, } from 'graphql-yoga';
|
|
4
|
-
import { Injectable, Logger } from '@nestjs/common';
|
|
5
|
-
import { AbstractGraphQLDriver, GqlSubscriptionService, } from '@nestjs/graphql';
|
|
6
|
-
export class AbstractYogaDriver extends AbstractGraphQLDriver {
|
|
7
|
-
yoga;
|
|
8
|
-
async start(options) {
|
|
9
|
-
const platformName = this.httpAdapterHost.httpAdapter.getType();
|
|
10
|
-
options = {
|
|
11
|
-
...options,
|
|
12
|
-
// disable error masking by default
|
|
13
|
-
maskedErrors: options.maskedErrors == null ? false : options.maskedErrors,
|
|
14
|
-
// disable graphiql in production
|
|
15
|
-
graphiql: options.graphiql == null ? process.env['NODE_ENV'] !== 'production' : options.graphiql,
|
|
16
|
-
};
|
|
17
|
-
if (platformName === 'express') {
|
|
18
|
-
return this.registerExpress(options);
|
|
19
|
-
}
|
|
20
|
-
if (platformName === 'fastify') {
|
|
21
|
-
return this.registerFastify(options);
|
|
22
|
-
}
|
|
23
|
-
throw new Error(`Provided HttpAdapter "${platformName}" not supported`);
|
|
24
|
-
}
|
|
25
|
-
async stop() {
|
|
26
|
-
// noop
|
|
27
|
-
}
|
|
28
|
-
registerExpress({ conditionalSchema, ...options }, { preStartHook } = {}) {
|
|
29
|
-
const app = this.httpAdapterHost.httpAdapter.getInstance();
|
|
30
|
-
preStartHook?.(app);
|
|
31
|
-
// nest's logger doesnt have the info method
|
|
32
|
-
class LoggerWithInfo extends Logger {
|
|
33
|
-
constructor(context) {
|
|
34
|
-
super(context);
|
|
35
|
-
}
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
-
info(message, ...args) {
|
|
38
|
-
this.log(message, ...args);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const schema = this.mergeConditionalSchema(conditionalSchema, options.schema);
|
|
42
|
-
const yoga = createYoga({
|
|
43
|
-
...options,
|
|
44
|
-
schema,
|
|
45
|
-
graphqlEndpoint: options.path,
|
|
46
|
-
// disable logging by default
|
|
47
|
-
// however, if `true` use nest logger
|
|
48
|
-
logging: options.logging == null
|
|
49
|
-
? false
|
|
50
|
-
: options.logging
|
|
51
|
-
? new LoggerWithInfo('YogaDriver')
|
|
52
|
-
: options.logging,
|
|
53
|
-
});
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
55
|
-
// @ts-ignore - TODO: fix types
|
|
56
|
-
this.yoga = yoga;
|
|
57
|
-
app.use(yoga.graphqlEndpoint, (req, res) => yoga(req, res, { req, res }));
|
|
58
|
-
}
|
|
59
|
-
registerFastify({ conditionalSchema, ...options }, { preStartHook } = {}) {
|
|
60
|
-
const app = this.httpAdapterHost.httpAdapter.getInstance();
|
|
61
|
-
preStartHook?.(app);
|
|
62
|
-
const schema = this.mergeConditionalSchema(conditionalSchema, options.schema);
|
|
63
|
-
const yoga = createYoga({
|
|
64
|
-
...options,
|
|
65
|
-
schema,
|
|
66
|
-
graphqlEndpoint: options.path,
|
|
67
|
-
// disable logging by default
|
|
68
|
-
// however, if `true` use fastify logger
|
|
69
|
-
logging: options.logging == null ? false : options.logging ? app.log : options.logging,
|
|
70
|
-
});
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
72
|
-
// @ts-ignore - TODO: fix types
|
|
73
|
-
this.yoga = yoga;
|
|
74
|
-
app.all(yoga.graphqlEndpoint, async (req, reply) => {
|
|
75
|
-
const response = await yoga.handleNodeRequestAndResponse(req, reply, {
|
|
76
|
-
req,
|
|
77
|
-
reply,
|
|
78
|
-
});
|
|
79
|
-
for (const [key, value] of response.headers.entries())
|
|
80
|
-
reply.header(key, value);
|
|
81
|
-
reply.status(response.status);
|
|
82
|
-
reply.send(response.body);
|
|
83
|
-
return reply;
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
mergeConditionalSchema(conditionalSchema, schema) {
|
|
87
|
-
let mergedSchema = schema;
|
|
88
|
-
if (conditionalSchema) {
|
|
89
|
-
mergedSchema = async (request) => {
|
|
90
|
-
const schemas = [];
|
|
91
|
-
if (schema) {
|
|
92
|
-
schemas.push(schema);
|
|
93
|
-
}
|
|
94
|
-
const conditionalSchemaResult = typeof conditionalSchema === 'function'
|
|
95
|
-
? await conditionalSchema(request)
|
|
96
|
-
: await conditionalSchema;
|
|
97
|
-
if (conditionalSchemaResult) {
|
|
98
|
-
schemas.push(conditionalSchemaResult);
|
|
99
|
-
}
|
|
100
|
-
return mergeSchemas({
|
|
101
|
-
schemas,
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
return mergedSchema;
|
|
106
|
-
}
|
|
107
|
-
subscriptionWithFilter(instanceRef, filterFn,
|
|
108
|
-
// disable next error, the original function in @nestjs/graphql is also untyped
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
110
|
-
createSubscribeContext) {
|
|
111
|
-
return async (...args) => {
|
|
112
|
-
return pipe(await createSubscribeContext()(...args), filter((payload) =>
|
|
113
|
-
// typecast the spread sliced args to avoid error TS 2556, see https://github.com/microsoft/TypeScript/issues/49802
|
|
114
|
-
filterFn.call(instanceRef, payload, ...args.slice(1))));
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
let YogaDriver = class YogaDriver extends AbstractYogaDriver {
|
|
119
|
-
subscriptionService;
|
|
120
|
-
async start(options) {
|
|
121
|
-
if (options.definitions?.path) {
|
|
122
|
-
if (!options.schema) {
|
|
123
|
-
throw new Error('Schema is required when generating definitions');
|
|
124
|
-
}
|
|
125
|
-
await this.graphQlFactory.generateDefinitions(printSchema(options.schema), options);
|
|
126
|
-
}
|
|
127
|
-
await super.start(options);
|
|
128
|
-
if (options.subscriptions) {
|
|
129
|
-
if (!options.schema) {
|
|
130
|
-
throw new Error('Schema is required when using subscriptions');
|
|
131
|
-
}
|
|
132
|
-
const config = options.subscriptions === true
|
|
133
|
-
? {
|
|
134
|
-
'graphql-ws': true,
|
|
135
|
-
}
|
|
136
|
-
: options.subscriptions;
|
|
137
|
-
if (config['graphql-ws']) {
|
|
138
|
-
config['graphql-ws'] = typeof config['graphql-ws'] === 'object' ? config['graphql-ws'] : {};
|
|
139
|
-
if (options.conditionalSchema) {
|
|
140
|
-
throw new Error(`
|
|
141
|
-
Conditional schema is not supported with graphql-ws.
|
|
142
|
-
`);
|
|
143
|
-
}
|
|
144
|
-
config['graphql-ws'].onSubscribe = async (ctx, _id, params) => {
|
|
145
|
-
const { schema, execute, subscribe, contextFactory, parse, validate } = this.yoga.getEnveloped({
|
|
146
|
-
...ctx,
|
|
147
|
-
// @ts-expect-error context extra is from graphql-ws/lib/use/ws
|
|
148
|
-
req: ctx.extra.request,
|
|
149
|
-
// @ts-expect-error context extra is from graphql-ws/lib/use/ws
|
|
150
|
-
socket: ctx.extra.socket,
|
|
151
|
-
params,
|
|
152
|
-
});
|
|
153
|
-
const args = {
|
|
154
|
-
schema,
|
|
155
|
-
operationName: params.operationName,
|
|
156
|
-
document: parse(params.query),
|
|
157
|
-
variableValues: params.variables,
|
|
158
|
-
contextValue: await contextFactory({ execute, subscribe }),
|
|
159
|
-
};
|
|
160
|
-
const errors = validate(args.schema, args.document);
|
|
161
|
-
if (errors.length)
|
|
162
|
-
return errors;
|
|
163
|
-
return args;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
if (config['subscriptions-transport-ws']) {
|
|
167
|
-
config['subscriptions-transport-ws'] =
|
|
168
|
-
typeof config['subscriptions-transport-ws'] === 'object'
|
|
169
|
-
? config['subscriptions-transport-ws']
|
|
170
|
-
: {};
|
|
171
|
-
if (options.conditionalSchema) {
|
|
172
|
-
throw new Error(`
|
|
173
|
-
Conditional schema is not supported with subscriptions-transport-ws.
|
|
174
|
-
`);
|
|
175
|
-
}
|
|
176
|
-
config['subscriptions-transport-ws'].onOperation = async (_msg, params, ws) => {
|
|
177
|
-
const { schema, execute, subscribe, contextFactory, parse, validate } = this.yoga.getEnveloped({
|
|
178
|
-
...params.context,
|
|
179
|
-
req:
|
|
180
|
-
// @ts-expect-error upgradeReq does exist but is untyped
|
|
181
|
-
ws.upgradeReq,
|
|
182
|
-
socket: ws,
|
|
183
|
-
params,
|
|
184
|
-
});
|
|
185
|
-
const args = {
|
|
186
|
-
schema,
|
|
187
|
-
operationName: params.operationName,
|
|
188
|
-
document: typeof params.query === 'string' ? parse(params.query) : params.query,
|
|
189
|
-
variables: params.variables,
|
|
190
|
-
context: await contextFactory({ execute, subscribe }),
|
|
191
|
-
};
|
|
192
|
-
const errors = validate(args.schema, args.document);
|
|
193
|
-
if (errors.length)
|
|
194
|
-
return errors;
|
|
195
|
-
return args;
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
this.subscriptionService = new GqlSubscriptionService({
|
|
199
|
-
schema: options.schema,
|
|
200
|
-
path: options.path,
|
|
201
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
202
|
-
// @ts-ignore
|
|
203
|
-
execute: (...args) => {
|
|
204
|
-
const contextValue =
|
|
205
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
206
|
-
// @ts-ignore
|
|
207
|
-
args[0].contextValue ||
|
|
208
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
209
|
-
// @ts-ignore
|
|
210
|
-
args[3];
|
|
211
|
-
if (!contextValue) {
|
|
212
|
-
throw new Error('Execution arguments are missing the context value');
|
|
213
|
-
}
|
|
214
|
-
return (contextValue
|
|
215
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
216
|
-
// @ts-ignore
|
|
217
|
-
.execute(...args));
|
|
218
|
-
},
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
220
|
-
// @ts-ignore
|
|
221
|
-
subscribe: (...args) => {
|
|
222
|
-
const contextValue =
|
|
223
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
224
|
-
// @ts-ignore
|
|
225
|
-
args[0].contextValue ||
|
|
226
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
227
|
-
// @ts-ignore
|
|
228
|
-
args?.[3];
|
|
229
|
-
if (!contextValue) {
|
|
230
|
-
throw new Error('Subscribe arguments are missing the context value');
|
|
231
|
-
}
|
|
232
|
-
return (contextValue
|
|
233
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- because we test both graphql v15 and v16
|
|
234
|
-
// @ts-ignore
|
|
235
|
-
.subscribe(...args));
|
|
236
|
-
},
|
|
237
|
-
...config,
|
|
238
|
-
}, this.httpAdapterHost.httpAdapter.getHttpServer());
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
async stop() {
|
|
242
|
-
await this.subscriptionService?.stop();
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
YogaDriver = __decorate([
|
|
246
|
-
Injectable()
|
|
247
|
-
], YogaDriver);
|
|
248
|
-
export { YogaDriver };
|
package/dist/package.json
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@graphql-yoga/nestjs",
|
|
3
|
-
"version": "3.19.0",
|
|
4
|
-
"description": "GraphQL Yoga driver for NestJS GraphQL.",
|
|
5
|
-
"sideEffects": false,
|
|
6
|
-
"peerDependencies": {
|
|
7
|
-
"@nestjs/common": "^11.0.0",
|
|
8
|
-
"@nestjs/core": "^11.0.0",
|
|
9
|
-
"@nestjs/graphql": "^13.0.0",
|
|
10
|
-
"graphql": "^15.0.0 || ^16.0.0",
|
|
11
|
-
"graphql-yoga": "workspace:^"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "https://github.com/graphql-hive/graphql-yoga.git",
|
|
16
|
-
"directory": "packages/nestjs"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"graphql",
|
|
20
|
-
"server",
|
|
21
|
-
"nestjs",
|
|
22
|
-
"nest",
|
|
23
|
-
"driver",
|
|
24
|
-
"graphql-yoga"
|
|
25
|
-
],
|
|
26
|
-
"author": "Denis Badurina <badurinadenis@gmail.com>",
|
|
27
|
-
"license": "MIT",
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=18.0.0"
|
|
30
|
-
},
|
|
31
|
-
"main": "cjs/index.js",
|
|
32
|
-
"module": "esm/index.js",
|
|
33
|
-
"typings": "typings/index.d.ts",
|
|
34
|
-
"typescript": {
|
|
35
|
-
"definition": "typings/index.d.ts"
|
|
36
|
-
},
|
|
37
|
-
"type": "module",
|
|
38
|
-
"exports": {
|
|
39
|
-
".": {
|
|
40
|
-
"require": {
|
|
41
|
-
"types": "./typings/index.d.cts",
|
|
42
|
-
"default": "./cjs/index.js"
|
|
43
|
-
},
|
|
44
|
-
"import": {
|
|
45
|
-
"types": "./typings/index.d.ts",
|
|
46
|
-
"default": "./esm/index.js"
|
|
47
|
-
},
|
|
48
|
-
"default": {
|
|
49
|
-
"types": "./typings/index.d.ts",
|
|
50
|
-
"default": "./esm/index.js"
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
"./package.json": "./package.json"
|
|
54
|
-
}
|
|
55
|
-
}
|
package/dist/typings/index.d.cts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Express, Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
2
|
-
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
3
|
-
import { YogaSchemaDefinition, YogaServerInstance, YogaServerOptions } from 'graphql-yoga';
|
|
4
|
-
import { AbstractGraphQLDriver, GqlModuleOptions, SubscriptionConfig } from '@nestjs/graphql';
|
|
5
|
-
export type YogaDriverPlatform = 'express' | 'fastify';
|
|
6
|
-
export type YogaDriverServerContext<Platform extends YogaDriverPlatform> = Platform extends 'fastify' ? {
|
|
7
|
-
req: FastifyRequest;
|
|
8
|
-
reply: FastifyReply;
|
|
9
|
-
} : {
|
|
10
|
-
req: ExpressRequest;
|
|
11
|
-
res: ExpressResponse;
|
|
12
|
-
};
|
|
13
|
-
export type YogaDriverServerOptions<Platform extends YogaDriverPlatform> = Omit<YogaServerOptions<YogaDriverServerContext<Platform>, never>, 'context' | 'schema' | 'graphqlEndpoint'> & {
|
|
14
|
-
conditionalSchema?: YogaSchemaDefinition<YogaDriverServerContext<Platform>, never> | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type YogaDriverServerInstance<Platform extends YogaDriverPlatform> = YogaServerInstance<YogaDriverServerContext<Platform>, never>;
|
|
17
|
-
export type YogaDriverConfig<Platform extends YogaDriverPlatform = 'express'> = GqlModuleOptions & YogaDriverServerOptions<Platform> & ({
|
|
18
|
-
/**
|
|
19
|
-
* Subscriptions configuration. Passing `true` will install only `graphql-ws`.
|
|
20
|
-
*/
|
|
21
|
-
subscriptions?: boolean | YogaDriverSubscriptionConfig;
|
|
22
|
-
conditionalSchema?: never;
|
|
23
|
-
} | {
|
|
24
|
-
/**
|
|
25
|
-
* TODO: Support conditional schema with subscriptions
|
|
26
|
-
*/
|
|
27
|
-
subscriptions?: never;
|
|
28
|
-
conditionalSchema?: YogaSchemaDefinition<YogaDriverServerContext<Platform>, never> | undefined;
|
|
29
|
-
});
|
|
30
|
-
export type YogaDriverSubscriptionConfig = {
|
|
31
|
-
'graphql-ws'?: Omit<SubscriptionConfig['graphql-ws'], 'onSubscribe'>;
|
|
32
|
-
'subscriptions-transport-ws'?: Omit<SubscriptionConfig['subscriptions-transport-ws'], 'onOperation'>;
|
|
33
|
-
};
|
|
34
|
-
export declare abstract class AbstractYogaDriver<Platform extends YogaDriverPlatform> extends AbstractGraphQLDriver<YogaDriverConfig<Platform>> {
|
|
35
|
-
protected yoga: YogaDriverServerInstance<Platform>;
|
|
36
|
-
start(options: YogaDriverConfig<Platform>): Promise<void>;
|
|
37
|
-
stop(): Promise<void>;
|
|
38
|
-
protected registerExpress({ conditionalSchema, ...options }: YogaDriverConfig<'express'>, { preStartHook }?: {
|
|
39
|
-
preStartHook?: (app: Express) => void;
|
|
40
|
-
}): void;
|
|
41
|
-
protected registerFastify({ conditionalSchema, ...options }: YogaDriverConfig<'fastify'>, { preStartHook }?: {
|
|
42
|
-
preStartHook?: (app: FastifyInstance) => void;
|
|
43
|
-
}): void;
|
|
44
|
-
private mergeConditionalSchema;
|
|
45
|
-
subscriptionWithFilter<TPayload, TVariables, TContext>(instanceRef: unknown, filterFn: (payload: TPayload, variables: TVariables, context: TContext) => boolean | Promise<boolean>, createSubscribeContext: Function): (...args: [TPayload, TVariables, TContext]) => Promise<import("graphql-yoga").Repeater<TPayload, void, unknown>>;
|
|
46
|
-
}
|
|
47
|
-
export declare class YogaDriver<Platform extends YogaDriverPlatform = 'express'> extends AbstractYogaDriver<Platform> {
|
|
48
|
-
private subscriptionService?;
|
|
49
|
-
start(options: YogaDriverConfig<Platform>): Promise<void>;
|
|
50
|
-
stop(): Promise<void>;
|
|
51
|
-
}
|
package/dist/typings/index.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { Express, Request as ExpressRequest, Response as ExpressResponse } from 'express';
|
|
2
|
-
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
3
|
-
import { YogaSchemaDefinition, YogaServerInstance, YogaServerOptions } from 'graphql-yoga';
|
|
4
|
-
import { AbstractGraphQLDriver, GqlModuleOptions, SubscriptionConfig } from '@nestjs/graphql';
|
|
5
|
-
export type YogaDriverPlatform = 'express' | 'fastify';
|
|
6
|
-
export type YogaDriverServerContext<Platform extends YogaDriverPlatform> = Platform extends 'fastify' ? {
|
|
7
|
-
req: FastifyRequest;
|
|
8
|
-
reply: FastifyReply;
|
|
9
|
-
} : {
|
|
10
|
-
req: ExpressRequest;
|
|
11
|
-
res: ExpressResponse;
|
|
12
|
-
};
|
|
13
|
-
export type YogaDriverServerOptions<Platform extends YogaDriverPlatform> = Omit<YogaServerOptions<YogaDriverServerContext<Platform>, never>, 'context' | 'schema' | 'graphqlEndpoint'> & {
|
|
14
|
-
conditionalSchema?: YogaSchemaDefinition<YogaDriverServerContext<Platform>, never> | undefined;
|
|
15
|
-
};
|
|
16
|
-
export type YogaDriverServerInstance<Platform extends YogaDriverPlatform> = YogaServerInstance<YogaDriverServerContext<Platform>, never>;
|
|
17
|
-
export type YogaDriverConfig<Platform extends YogaDriverPlatform = 'express'> = GqlModuleOptions & YogaDriverServerOptions<Platform> & ({
|
|
18
|
-
/**
|
|
19
|
-
* Subscriptions configuration. Passing `true` will install only `graphql-ws`.
|
|
20
|
-
*/
|
|
21
|
-
subscriptions?: boolean | YogaDriverSubscriptionConfig;
|
|
22
|
-
conditionalSchema?: never;
|
|
23
|
-
} | {
|
|
24
|
-
/**
|
|
25
|
-
* TODO: Support conditional schema with subscriptions
|
|
26
|
-
*/
|
|
27
|
-
subscriptions?: never;
|
|
28
|
-
conditionalSchema?: YogaSchemaDefinition<YogaDriverServerContext<Platform>, never> | undefined;
|
|
29
|
-
});
|
|
30
|
-
export type YogaDriverSubscriptionConfig = {
|
|
31
|
-
'graphql-ws'?: Omit<SubscriptionConfig['graphql-ws'], 'onSubscribe'>;
|
|
32
|
-
'subscriptions-transport-ws'?: Omit<SubscriptionConfig['subscriptions-transport-ws'], 'onOperation'>;
|
|
33
|
-
};
|
|
34
|
-
export declare abstract class AbstractYogaDriver<Platform extends YogaDriverPlatform> extends AbstractGraphQLDriver<YogaDriverConfig<Platform>> {
|
|
35
|
-
protected yoga: YogaDriverServerInstance<Platform>;
|
|
36
|
-
start(options: YogaDriverConfig<Platform>): Promise<void>;
|
|
37
|
-
stop(): Promise<void>;
|
|
38
|
-
protected registerExpress({ conditionalSchema, ...options }: YogaDriverConfig<'express'>, { preStartHook }?: {
|
|
39
|
-
preStartHook?: (app: Express) => void;
|
|
40
|
-
}): void;
|
|
41
|
-
protected registerFastify({ conditionalSchema, ...options }: YogaDriverConfig<'fastify'>, { preStartHook }?: {
|
|
42
|
-
preStartHook?: (app: FastifyInstance) => void;
|
|
43
|
-
}): void;
|
|
44
|
-
private mergeConditionalSchema;
|
|
45
|
-
subscriptionWithFilter<TPayload, TVariables, TContext>(instanceRef: unknown, filterFn: (payload: TPayload, variables: TVariables, context: TContext) => boolean | Promise<boolean>, createSubscribeContext: Function): (...args: [TPayload, TVariables, TContext]) => Promise<import("graphql-yoga").Repeater<TPayload, void, unknown>>;
|
|
46
|
-
}
|
|
47
|
-
export declare class YogaDriver<Platform extends YogaDriverPlatform = 'express'> extends AbstractYogaDriver<Platform> {
|
|
48
|
-
private subscriptionService?;
|
|
49
|
-
start(options: YogaDriverConfig<Platform>): Promise<void>;
|
|
50
|
-
stop(): Promise<void>;
|
|
51
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|