@teambit/graphql 1.0.108 → 1.0.109
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/artifacts/preview/teambit_harmony_graphql-preview.js +1 -0
- package/dist/{preview-1703647408454.js → preview-1703698405864.js} +2 -2
- package/package.json +6 -6
- package/create-link.ts +0 -20
- package/graphql-error.ts +0 -13
- package/graphql-server.ts +0 -5
- package/graphql.aspect.ts +0 -9
- package/graphql.main.runtime.ts +0 -328
- package/index.ts +0 -8
- package/logging.ts +0 -26
- package/schema.ts +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["teambit.harmony/graphql-preview"]=t():e["teambit.harmony/graphql-preview"]=t()}(self,(()=>(()=>{"use strict";var e={42373:(e,t,o)=>{var r={id:"teambit.harmony/graphql@1.0.109",homepage:"https://bit.cloud/teambit/harmony/graphql",exported:!0};function n(){const e=i(o(87363));return n=function(){return e},e}function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.Logo=void 0,n.__bit_component=r,i.__bit_component=r;const a=()=>n().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},n().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/brands/logo-grphql.svg"}));a.__bit_component=r,t.Logo=a},87363:e=>{e.exports=React}},t={};function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{o.r(r),o.d(r,{compositions:()=>d,compositions_metadata:()=>f,overview:()=>u});var e={};o.r(e),o.d(e,{default:()=>l});var t=o(42373);o(87363);const n=MdxJsReact,i=TeambitMdxUiMdxScopeContext;var a=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},p.apply(this,arguments)}var c={},s="wrapper";function l(e){var t=e.components,o=function(e,t){if(null==e)return{};var o,r,n=function(e,t){if(null==e)return{};var o,r,n={},i=Object.keys(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||(n[o]=e[o]);return n}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)o=i[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}(e,a);return(0,n.mdx)(s,p({},c,o,{components:t,mdxType:"MDXLayout"}),(0,n.mdx)(i.MDXScopeProvider,{components:{},mdxType:"MDXScopeProvider"}))}l.isMDXComponent=!0;const d=[t],u=[e],f={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),r})()));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@1.0.109/dist/graphql.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_graphql@1.0.109/dist/graphql.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/graphql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.109",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/harmony/graphql",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.harmony",
|
|
8
8
|
"name": "graphql",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.109"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@graphql-modules/core": "0.7.17",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"bufferutil": "4.0.3",
|
|
33
33
|
"@teambit/harmony": "0.4.6",
|
|
34
34
|
"@teambit/ui-foundation.ui.is-browser": "0.0.500",
|
|
35
|
-
"@teambit/cli": "0.0.
|
|
36
|
-
"@teambit/logger": "0.0.
|
|
35
|
+
"@teambit/cli": "0.0.841",
|
|
36
|
+
"@teambit/logger": "0.0.934",
|
|
37
37
|
"@teambit/toolbox.network.get-port": "1.0.4",
|
|
38
|
-
"@teambit/ui": "1.0.
|
|
38
|
+
"@teambit/ui": "1.0.109"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/cors": "2.8.10",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/mocha": "9.1.0",
|
|
46
46
|
"@types/jest": "^29.2.2",
|
|
47
47
|
"@types/testing-library__jest-dom": "^5.9.5",
|
|
48
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
|
48
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.14"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@apollo/client": "^3.6.0",
|
package/create-link.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { HttpLink, split } from '@apollo/client';
|
|
2
|
-
import { getMainDefinition } from '@apollo/client/utilities';
|
|
3
|
-
import type { WebSocketLink } from '@apollo/client/link/ws';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* create a link which splits routes data depending on type of operation.
|
|
7
|
-
* @param httpLink http link for apollo graphql
|
|
8
|
-
* @param wsLink web socket link for apollo graphql
|
|
9
|
-
*/
|
|
10
|
-
export function createSplitLink(httpLink: HttpLink, wsLink: WebSocketLink) {
|
|
11
|
-
return split(
|
|
12
|
-
// split based on operation type
|
|
13
|
-
({ query }) => {
|
|
14
|
-
const definition = getMainDefinition(query);
|
|
15
|
-
return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';
|
|
16
|
-
},
|
|
17
|
-
wsLink,
|
|
18
|
-
httpLink
|
|
19
|
-
);
|
|
20
|
-
}
|
package/graphql-error.ts
DELETED
package/graphql-server.ts
DELETED
package/graphql.aspect.ts
DELETED
package/graphql.main.runtime.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { mergeSchemas } from '@graphql-tools/schema';
|
|
2
|
-
import NoIntrospection from 'graphql-disable-introspection';
|
|
3
|
-
import { GraphQLModule } from '@graphql-modules/core';
|
|
4
|
-
import { MainRuntime } from '@teambit/cli';
|
|
5
|
-
import { Harmony, Slot, SlotRegistry } from '@teambit/harmony';
|
|
6
|
-
import { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
7
|
-
import express, { Express } from 'express';
|
|
8
|
-
import { graphqlHTTP } from 'express-graphql';
|
|
9
|
-
import { Port } from '@teambit/toolbox.network.get-port';
|
|
10
|
-
import { execute, subscribe } from 'graphql';
|
|
11
|
-
import { PubSubEngine, PubSub } from 'graphql-subscriptions';
|
|
12
|
-
import { createServer, Server } from 'http';
|
|
13
|
-
import httpProxy from 'http-proxy';
|
|
14
|
-
import { SubscriptionServer } from 'subscriptions-transport-ws';
|
|
15
|
-
import cors from 'cors';
|
|
16
|
-
import { GraphQLServer } from './graphql-server';
|
|
17
|
-
import { createRemoteSchemas } from './create-remote-schemas';
|
|
18
|
-
import { GraphqlAspect } from './graphql.aspect';
|
|
19
|
-
import { Schema } from './schema';
|
|
20
|
-
|
|
21
|
-
export enum Verb {
|
|
22
|
-
WRITE = 'write',
|
|
23
|
-
READ = 'read',
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type GraphQLConfig = {
|
|
27
|
-
port: number;
|
|
28
|
-
subscriptionsPortRange: number[];
|
|
29
|
-
subscriptionsPath: string;
|
|
30
|
-
disableCors?: boolean;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export type GraphQLServerSlot = SlotRegistry<GraphQLServer>;
|
|
34
|
-
|
|
35
|
-
export type SchemaSlot = SlotRegistry<Schema>;
|
|
36
|
-
|
|
37
|
-
export type PubSubSlot = SlotRegistry<PubSubEngine>;
|
|
38
|
-
|
|
39
|
-
export type GraphQLServerOptions = {
|
|
40
|
-
schemaSlot?: SchemaSlot;
|
|
41
|
-
app?: Express;
|
|
42
|
-
graphiql?: boolean;
|
|
43
|
-
disableIntrospection?: boolean;
|
|
44
|
-
remoteSchemas?: GraphQLServer[];
|
|
45
|
-
subscriptionsPortRange?: number[];
|
|
46
|
-
onWsConnect?: Function;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export class GraphqlMain {
|
|
50
|
-
constructor(
|
|
51
|
-
/**
|
|
52
|
-
* extension config
|
|
53
|
-
*/
|
|
54
|
-
readonly config: GraphQLConfig,
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* slot for registering graphql modules
|
|
58
|
-
*/
|
|
59
|
-
private moduleSlot: SchemaSlot,
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* harmony context.
|
|
63
|
-
*/
|
|
64
|
-
private context: Harmony,
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* logger extension.
|
|
68
|
-
*/
|
|
69
|
-
readonly logger: Logger,
|
|
70
|
-
|
|
71
|
-
private graphQLServerSlot: GraphQLServerSlot,
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* graphql pubsub. allows to emit events to clients.
|
|
75
|
-
*/
|
|
76
|
-
private pubSubSlot: PubSubSlot
|
|
77
|
-
) {}
|
|
78
|
-
|
|
79
|
-
get pubsub(): PubSubEngine {
|
|
80
|
-
const pubSubSlots = this.pubSubSlot.values();
|
|
81
|
-
if (pubSubSlots.length) return pubSubSlots[0];
|
|
82
|
-
return new PubSub();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
private modules = new Map<string, GraphQLModule>();
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* returns the schema for a specific aspect by its id.
|
|
89
|
-
*/
|
|
90
|
-
getSchema(aspectId: string) {
|
|
91
|
-
return this.moduleSlot.get(aspectId);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* get multiple schema by aspect ids.
|
|
96
|
-
*/
|
|
97
|
-
getSchemas(aspectIds: string[]) {
|
|
98
|
-
return this.moduleSlot
|
|
99
|
-
.toArray()
|
|
100
|
-
.filter(([aspectId]) => {
|
|
101
|
-
return aspectIds.includes(aspectId);
|
|
102
|
-
})
|
|
103
|
-
.map(([, schema]) => {
|
|
104
|
-
return schema;
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async createServer(options: GraphQLServerOptions) {
|
|
109
|
-
const { graphiql = true, disableIntrospection } = options;
|
|
110
|
-
const localSchema = this.createRootModule(options.schemaSlot);
|
|
111
|
-
const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());
|
|
112
|
-
const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);
|
|
113
|
-
const schema = mergeSchemas({
|
|
114
|
-
schemas,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// TODO: @guy please consider to refactor to express extension.
|
|
118
|
-
const app = options.app || express();
|
|
119
|
-
if (!this.config.disableCors) {
|
|
120
|
-
app.use(
|
|
121
|
-
// @ts-ignore todo: it's not clear what's the issue.
|
|
122
|
-
cors({
|
|
123
|
-
origin(origin, callback) {
|
|
124
|
-
callback(null, true);
|
|
125
|
-
},
|
|
126
|
-
credentials: true,
|
|
127
|
-
})
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
app.use(
|
|
132
|
-
'/graphql',
|
|
133
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
134
|
-
graphqlHTTP((request, res, params) => ({
|
|
135
|
-
customFormatErrorFn: (err) => {
|
|
136
|
-
this.logger.error('graphql got an error during running the following query:', params);
|
|
137
|
-
this.logger.error('graphql error ', err);
|
|
138
|
-
return Object.assign(err, {
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code,
|
|
143
|
-
});
|
|
144
|
-
},
|
|
145
|
-
schema,
|
|
146
|
-
rootValue: request,
|
|
147
|
-
graphiql,
|
|
148
|
-
validationRules: disableIntrospection ? [NoIntrospection] : undefined,
|
|
149
|
-
}))
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
const server = createServer(app);
|
|
153
|
-
const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange;
|
|
154
|
-
const subscriptionServerPort = await this.getPort(subscriptionsPort);
|
|
155
|
-
const { port } = await this.createSubscription(options, subscriptionServerPort);
|
|
156
|
-
this.proxySubscription(server, port);
|
|
157
|
-
|
|
158
|
-
return server;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* register a new graphql server.
|
|
163
|
-
*/
|
|
164
|
-
registerServer(server: GraphQLServer) {
|
|
165
|
-
this.graphQLServerSlot.register(server);
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* register a pubsub client
|
|
171
|
-
*/
|
|
172
|
-
registerPubSub(pubsub: PubSubEngine) {
|
|
173
|
-
const pubSubSlots = this.pubSubSlot.toArray();
|
|
174
|
-
if (pubSubSlots.length) throw new Error('can not register more then one pubsub provider');
|
|
175
|
-
this.pubSubSlot.register(pubsub);
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* start a graphql server.
|
|
181
|
-
*/
|
|
182
|
-
async listen(port?: number, server?: Server, app?: Express) {
|
|
183
|
-
const serverPort = port || this.config.port;
|
|
184
|
-
const subServer = server || (await this.createServer({ app }));
|
|
185
|
-
|
|
186
|
-
subServer.listen(serverPort, () => {
|
|
187
|
-
this.logger.info(`API Server over HTTP is now running on http://localhost:${serverPort}`);
|
|
188
|
-
this.logger.info(
|
|
189
|
-
`API Server over web socket with subscriptions is now running on ws://localhost:${serverPort}/${this.config.subscriptionsPath}`
|
|
190
|
-
);
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* register a new graphql module.
|
|
196
|
-
*/
|
|
197
|
-
register(schema: Schema) {
|
|
198
|
-
// const module = new GraphQLModule(schema);
|
|
199
|
-
this.moduleSlot.register(schema);
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
private async getPort(range: number[]) {
|
|
204
|
-
const [from, to] = range;
|
|
205
|
-
return Port.getPort(from, to);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/** create Subscription server with different port */
|
|
209
|
-
|
|
210
|
-
private async createSubscription(options: GraphQLServerOptions, port: number) {
|
|
211
|
-
// Create WebSocket listener server
|
|
212
|
-
const websocketServer = createServer((request, response) => {
|
|
213
|
-
response.writeHead(404);
|
|
214
|
-
response.end();
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// Bind it to port and start listening
|
|
218
|
-
websocketServer.listen(port, () =>
|
|
219
|
-
this.logger.debug(`Websocket Server is now running on http://localhost:${port}`)
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
const localSchema = this.createRootModule(options.schemaSlot);
|
|
223
|
-
const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());
|
|
224
|
-
const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);
|
|
225
|
-
const schema = mergeSchemas({
|
|
226
|
-
schemas,
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
230
|
-
const subServer = new SubscriptionServer(
|
|
231
|
-
{
|
|
232
|
-
execute,
|
|
233
|
-
subscribe,
|
|
234
|
-
schema,
|
|
235
|
-
onConnect: options.onWsConnect,
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
server: websocketServer,
|
|
239
|
-
path: this.config.subscriptionsPath,
|
|
240
|
-
}
|
|
241
|
-
);
|
|
242
|
-
return { subServer, port };
|
|
243
|
-
}
|
|
244
|
-
/** proxy ws Subscription server to avoid conflict with different websocket connections */
|
|
245
|
-
|
|
246
|
-
private proxySubscription(server: Server, port: number) {
|
|
247
|
-
const proxServer = httpProxy.createProxyServer();
|
|
248
|
-
const subscriptionsPath = this.config.subscriptionsPath;
|
|
249
|
-
server.on('upgrade', function (req, socket, head) {
|
|
250
|
-
if (req.url === subscriptionsPath) {
|
|
251
|
-
proxServer.ws(req, socket, head, { target: { host: 'localhost', port } });
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
private createRootModule(schemaSlot?: SchemaSlot) {
|
|
257
|
-
const modules = this.buildModules(schemaSlot);
|
|
258
|
-
|
|
259
|
-
return new GraphQLModule({
|
|
260
|
-
imports: modules,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
private buildModules(schemaSlot?: SchemaSlot) {
|
|
265
|
-
const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray();
|
|
266
|
-
return schemaSlots.map(([extensionId, schema]) => {
|
|
267
|
-
const moduleDeps = this.getModuleDependencies(extensionId);
|
|
268
|
-
|
|
269
|
-
const module = new GraphQLModule({
|
|
270
|
-
typeDefs: schema.typeDefs,
|
|
271
|
-
resolvers: schema.resolvers,
|
|
272
|
-
schemaDirectives: schema.schemaDirectives,
|
|
273
|
-
imports: moduleDeps,
|
|
274
|
-
context: (session) => {
|
|
275
|
-
return {
|
|
276
|
-
...session,
|
|
277
|
-
verb: session?.headers?.['x-verb'] || Verb.READ,
|
|
278
|
-
};
|
|
279
|
-
},
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
this.modules.set(extensionId, module);
|
|
283
|
-
|
|
284
|
-
return module;
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
private getModuleDependencies(extensionId: string): GraphQLModule[] {
|
|
289
|
-
const extension = this.context.extensions.get(extensionId);
|
|
290
|
-
if (!extension) throw new Error(`aspect ${extensionId} was not found`);
|
|
291
|
-
const deps = this.context.getDependencies(extension);
|
|
292
|
-
const ids = deps.map((dep) => dep.id);
|
|
293
|
-
|
|
294
|
-
// @ts-ignore check :TODO why types are breaking here.
|
|
295
|
-
return Array.from(this.modules.entries())
|
|
296
|
-
.map(([depId, module]) => {
|
|
297
|
-
const dep = ids.includes(depId);
|
|
298
|
-
if (!dep) return undefined;
|
|
299
|
-
return module;
|
|
300
|
-
})
|
|
301
|
-
.filter((module) => !!module);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
static slots = [Slot.withType<Schema>(), Slot.withType<GraphQLServer>(), Slot.withType<PubSubSlot>()];
|
|
305
|
-
|
|
306
|
-
static defaultConfig = {
|
|
307
|
-
port: 4000,
|
|
308
|
-
subscriptionsPortRange: [2000, 2100],
|
|
309
|
-
disableCors: false,
|
|
310
|
-
subscriptionsPath: '/subscriptions',
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
static runtime = MainRuntime;
|
|
314
|
-
static dependencies = [LoggerAspect];
|
|
315
|
-
|
|
316
|
-
static async provider(
|
|
317
|
-
[loggerFactory]: [LoggerMain],
|
|
318
|
-
config: GraphQLConfig,
|
|
319
|
-
[moduleSlot, graphQLServerSlot, pubSubSlot]: [SchemaSlot, GraphQLServerSlot, PubSubSlot],
|
|
320
|
-
context: Harmony
|
|
321
|
-
) {
|
|
322
|
-
const logger = loggerFactory.createLogger(GraphqlAspect.id);
|
|
323
|
-
const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot);
|
|
324
|
-
return graphqlMain;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
GraphqlAspect.addRuntime(GraphqlMain);
|
package/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { GraphqlAspect, GraphqlAspect as default } from './graphql.aspect';
|
|
2
|
-
|
|
3
|
-
export type { Schema } from './schema';
|
|
4
|
-
export type { GraphqlMain, SchemaSlot } from './graphql.main.runtime';
|
|
5
|
-
export type { GraphqlUI, GraphQLClient } from './graphql.ui.runtime';
|
|
6
|
-
export type { GraphQLServer } from './graphql-server';
|
|
7
|
-
export { GraphQLProvider } from './graphql-provider';
|
|
8
|
-
export { GraphQlError } from './graphql-error';
|
package/logging.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ErrorResponse } from '@apollo/client/link/error';
|
|
2
|
-
|
|
3
|
-
export function logError({ graphQLErrors, networkError, operation }: ErrorResponse) {
|
|
4
|
-
if (graphQLErrors)
|
|
5
|
-
graphQLErrors.forEach(({ message, locations, path }) =>
|
|
6
|
-
// eslint-disable-next-line no-console
|
|
7
|
-
console.error(`[gql] error on "${operation.operationName}" - "${message}"`, locations, path)
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line no-console
|
|
11
|
-
if (networkError) console.error('[gql] network error', `"${operation.operationName}"`, networkError);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// // // a fetch monkey patch with logs. useful to debug gql
|
|
15
|
-
// function loggingCrossFetch(...p: Parameters<typeof fetch>) {
|
|
16
|
-
// const [url, init] = p;
|
|
17
|
-
// const headers = init?.headers;
|
|
18
|
-
// const body = init?.body;
|
|
19
|
-
|
|
20
|
-
// console.debug('[gql]', 'fetching', url, body, { headers });
|
|
21
|
-
// const promise = crossFetch(...p);
|
|
22
|
-
// promise
|
|
23
|
-
// .then((result) => console.debug('[gql]', 'finished', result))
|
|
24
|
-
// .catch((err) => console.debug('[gql]', 'error', err));
|
|
25
|
-
// return promise;
|
|
26
|
-
// }
|
package/schema.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { DocumentNode } from 'graphql';
|
|
2
|
-
import type { SchemaDirectives } from '@graphql-modules/core';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* graphql schema for an extension.
|
|
6
|
-
*/
|
|
7
|
-
export type Schema = {
|
|
8
|
-
typeDefs?: string | DocumentNode;
|
|
9
|
-
resolvers?: { [key: string]: any };
|
|
10
|
-
schemaDirectives?: SchemaDirectives;
|
|
11
|
-
};
|