@teambit/graphql 1.0.864 → 1.0.866
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/dist/create-link.d.ts +2 -2
- package/dist/create-link.js.map +1 -1
- package/dist/graphql.main.runtime.d.ts +4 -0
- package/dist/graphql.main.runtime.js +77 -1
- package/dist/graphql.main.runtime.js.map +1 -1
- package/dist/graphql.ui.runtime.d.ts +12 -4
- package/dist/graphql.ui.runtime.js +86 -7
- package/dist/graphql.ui.runtime.js.map +1 -1
- package/dist/{preview-1768409075705.js → preview-1768422783100.js} +2 -2
- package/graphql.ui.runtime.tsx +80 -8
- package/package.json +3 -3
package/dist/create-link.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApolloLink } from '@apollo/client';
|
|
2
2
|
import type { WebSocketLink } from '@apollo/client/link/ws';
|
|
3
3
|
/**
|
|
4
4
|
* create a link which splits routes data depending on type of operation.
|
|
5
5
|
* @param httpLink http link for apollo graphql
|
|
6
6
|
* @param wsLink web socket link for apollo graphql
|
|
7
7
|
*/
|
|
8
|
-
export declare function createSplitLink(httpLink:
|
|
8
|
+
export declare function createSplitLink(httpLink: ApolloLink, wsLink: WebSocketLink): ApolloLink;
|
package/dist/create-link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_client","data","require","_utilities","createSplitLink","httpLink","wsLink","split","query","definition","getMainDefinition","kind","operation"],"sources":["create-link.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"names":["_client","data","require","_utilities","createSplitLink","httpLink","wsLink","split","query","definition","getMainDefinition","kind","operation"],"sources":["create-link.ts"],"sourcesContent":["import type { ApolloLink } from '@apollo/client';\nimport { split } from '@apollo/client';\nimport { getMainDefinition } from '@apollo/client/utilities';\nimport type { WebSocketLink } from '@apollo/client/link/ws';\n\n/**\n * create a link which splits routes data depending on type of operation.\n * @param httpLink http link for apollo graphql\n * @param wsLink web socket link for apollo graphql\n */\nexport function createSplitLink(httpLink: ApolloLink, wsLink: WebSocketLink) {\n return split(\n // split based on operation type\n ({ query }) => {\n const definition = getMainDefinition(query);\n return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';\n },\n wsLink,\n httpLink\n );\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA;AACA;AACA;AACA;AACA;AACO,SAASG,eAAeA,CAACC,QAAoB,EAAEC,MAAqB,EAAE;EAC3E,OAAO,IAAAC,eAAK;EACV;EACA,CAAC;IAAEC;EAAM,CAAC,KAAK;IACb,MAAMC,UAAU,GAAG,IAAAC,8BAAiB,EAACF,KAAK,CAAC;IAC3C,OAAOC,UAAU,CAACE,IAAI,KAAK,qBAAqB,IAAIF,UAAU,CAACG,SAAS,KAAK,cAAc;EAC7F,CAAC,EACDN,MAAM,EACND,QACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -16,6 +16,8 @@ export type GraphQLConfig = {
|
|
|
16
16
|
subscriptionsPortRange: number[];
|
|
17
17
|
subscriptionsPath: string;
|
|
18
18
|
disableCors?: boolean;
|
|
19
|
+
enableBatching?: boolean;
|
|
20
|
+
batchMax?: number;
|
|
19
21
|
};
|
|
20
22
|
export type GraphQLServerSlot = SlotRegistry<GraphQLServer>;
|
|
21
23
|
export type SchemaSlot = SlotRegistry<Schema | (() => Schema)>;
|
|
@@ -120,6 +122,8 @@ export declare class GraphqlMain {
|
|
|
120
122
|
subscriptionsPortRange: number[];
|
|
121
123
|
disableCors: boolean;
|
|
122
124
|
subscriptionsPath: string;
|
|
125
|
+
enableBatching: boolean;
|
|
126
|
+
batchMax: number;
|
|
123
127
|
};
|
|
124
128
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
125
129
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
@@ -215,6 +215,80 @@ class GraphqlMain {
|
|
|
215
215
|
credentials: true
|
|
216
216
|
}));
|
|
217
217
|
}
|
|
218
|
+
const batchingEnabled = this.config.enableBatching;
|
|
219
|
+
if (batchingEnabled) {
|
|
220
|
+
app.use('/graphql', _express().default.json());
|
|
221
|
+
app.use('/graphql', async (req, res, next) => {
|
|
222
|
+
if (req.method !== 'POST') return next();
|
|
223
|
+
if (!Array.isArray(req.body)) return next();
|
|
224
|
+
if (!req.is('application/json')) return next();
|
|
225
|
+
const max = this.config.batchMax ?? 20;
|
|
226
|
+
if (req.body.length > max) {
|
|
227
|
+
return res.status(413).json([{
|
|
228
|
+
errors: [{
|
|
229
|
+
message: `Batch size ${req.body.length} exceeds max ${max}`
|
|
230
|
+
}]
|
|
231
|
+
}]);
|
|
232
|
+
}
|
|
233
|
+
const formatError = options.customFormatErrorFn ?? (err => {
|
|
234
|
+
this.logger.error('graphql got an error during running the following query:', req.body);
|
|
235
|
+
this.logger.error('graphql error ', err);
|
|
236
|
+
return Object.assign(err, {
|
|
237
|
+
// @ts-ignore
|
|
238
|
+
ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,
|
|
239
|
+
// @ts-ignore
|
|
240
|
+
HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err?.originalError?.code
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
const validationRules = disableIntrospection ? [_graphqlDisableIntrospection().default] : _graphql().specifiedRules;
|
|
244
|
+
req.res = res;
|
|
245
|
+
const execFn = options.customExecuteFn ?? _graphql().execute;
|
|
246
|
+
try {
|
|
247
|
+
const ops = req.body;
|
|
248
|
+
const results = await Promise.all(ops.map(async op => {
|
|
249
|
+
if (!op?.query || typeof op.query !== 'string') {
|
|
250
|
+
return {
|
|
251
|
+
errors: [{
|
|
252
|
+
message: 'Must provide query string.'
|
|
253
|
+
}]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
const document = (0, _graphql().parse)(op.query);
|
|
258
|
+
const validationErrors = (0, _graphql().validate)(schema, document, validationRules);
|
|
259
|
+
if (validationErrors.length) {
|
|
260
|
+
return {
|
|
261
|
+
errors: validationErrors.map(formatError)
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const result = await execFn({
|
|
265
|
+
schema,
|
|
266
|
+
document,
|
|
267
|
+
rootValue: req,
|
|
268
|
+
contextValue: req,
|
|
269
|
+
variableValues: op.variables,
|
|
270
|
+
operationName: op.operationName
|
|
271
|
+
});
|
|
272
|
+
if (result?.errors?.length) {
|
|
273
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
274
|
+
errors: result.errors.map(formatError)
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
return result;
|
|
278
|
+
} catch (err) {
|
|
279
|
+
this.logger.error('graphql batch error', err);
|
|
280
|
+
const e = err instanceof Error ? err : new Error(err?.message ?? String(err));
|
|
281
|
+
return {
|
|
282
|
+
errors: [formatError(e)]
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
}));
|
|
286
|
+
return res.status(200).json(results);
|
|
287
|
+
} catch (err) {
|
|
288
|
+
return next(err);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
218
292
|
app.use('/graphql',
|
|
219
293
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
220
294
|
(0, _expressGraphql().graphqlHTTP)((request, res, params) => ({
|
|
@@ -391,7 +465,9 @@ _defineProperty(GraphqlMain, "defaultConfig", {
|
|
|
391
465
|
port: 4000,
|
|
392
466
|
subscriptionsPortRange: [2000, 2100],
|
|
393
467
|
disableCors: false,
|
|
394
|
-
subscriptionsPath: '/subscriptions'
|
|
468
|
+
subscriptionsPath: '/subscriptions',
|
|
469
|
+
enableBatching: false,
|
|
470
|
+
batchMax: 20
|
|
395
471
|
});
|
|
396
472
|
_defineProperty(GraphqlMain, "runtime", _cli().MainRuntime);
|
|
397
473
|
_defineProperty(GraphqlMain, "dependencies", [_logger().LoggerAspect]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_schema","data","require","_graphqlDisableIntrospection","_interopRequireDefault","_core","_cli","_harmony","_logger","_express","_expressGraphql","_toolboxNetwork","_graphql","_graphqlSubscriptions","_http","_httpProxy","_subscriptionsTransportWs","_cors","_createRemoteSchemas","_graphql2","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Verb","exports","GraphqlMain","constructor","config","moduleSlot","context","logger","graphQLServerSlot","pubSubSlot","Map","pubsub","pubSubSlots","values","PubSub","getSchema","aspectId","schemaOrFunc","get","undefined","schema","execute","getSchemas","aspectIds","toArray","includes","map","createServer","options","graphiql","disableIntrospection","localSchema","createRootModule","schemaSlot","remoteSchemas","createRemoteSchemas","schemas","concat","x","mergeSchemas","app","express","disableCors","use","cors","origin","callback","credentials","graphqlHTTP","request","res","params","extensions","customExecuteFn","customFormatErrorFn","err","error","assign","ERR_CODE","originalError","errors","name","HTTP_CODE","code","rootValue","validationRules","NoIntrospection","server","subscriptionsPort","subscriptionsPortRange","subscriptionServerPort","getPort","port","createSubscription","proxySubscription","registerServer","register","registerPubSub","Error","listen","serverPort","subServer","info","subscriptionsPath","range","from","to","Port","websocketServer","response","writeHead","end","debug","SubscriptionServer","subscribe","onConnect","onWsConnect","path","proxServer","httpProxy","createProxyServer","on","req","socket","head","url","ws","target","host","modules","buildModules","GraphQLModule","imports","schemaSlots","extensionId","moduleDeps","getModuleDependencies","module","typeDefs","resolvers","schemaDirectives","session","verb","headers","READ","set","extension","deps","getDependencies","ids","dep","id","Array","entries","depId","provider","loggerFactory","createLogger","GraphqlAspect","graphqlMain","Slot","withType","MainRuntime","LoggerAspect","addRuntime"],"sources":["graphql.main.runtime.ts"],"sourcesContent":["import { mergeSchemas } from '@graphql-tools/schema';\nimport NoIntrospection from 'graphql-disable-introspection';\nimport { GraphQLModule } from '@graphql-modules/core';\nimport { MainRuntime } from '@teambit/cli';\nimport type { Harmony, SlotRegistry } from '@teambit/harmony';\nimport { Slot } from '@teambit/harmony';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { Express } from 'express';\nimport express from 'express';\nimport { graphqlHTTP, type RequestInfo } from 'express-graphql';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { execute, subscribe } from 'graphql';\nimport type { PubSubEngine } from 'graphql-subscriptions';\nimport { PubSub } from 'graphql-subscriptions';\nimport type { Server } from 'http';\nimport { createServer } from 'http';\nimport httpProxy from 'http-proxy';\nimport { SubscriptionServer } from 'subscriptions-transport-ws';\nimport cors from 'cors';\nimport type { GraphQLServer } from './graphql-server';\nimport { createRemoteSchemas } from './create-remote-schemas';\nimport { GraphqlAspect } from './graphql.aspect';\nimport type { Schema } from './schema';\n\nexport enum Verb {\n WRITE = 'write',\n READ = 'read',\n}\n\nexport type GraphQLConfig = {\n port: number;\n subscriptionsPortRange: number[];\n subscriptionsPath: string;\n disableCors?: boolean;\n};\n\nexport type GraphQLServerSlot = SlotRegistry<GraphQLServer>;\n\nexport type SchemaSlot = SlotRegistry<Schema | (() => Schema)>;\n\nexport type PubSubSlot = SlotRegistry<PubSubEngine>;\n\nexport type GraphQLServerOptions = {\n schemaSlot?: SchemaSlot;\n app?: Express;\n graphiql?: boolean;\n disableIntrospection?: boolean;\n remoteSchemas?: GraphQLServer[];\n subscriptionsPortRange?: number[];\n onWsConnect?: Function;\n customExecuteFn?: (args: any) => Promise<any>;\n customFormatErrorFn?: (args: any) => any;\n extensions?: (info: RequestInfo) => Promise<any>;\n};\n\nexport class GraphqlMain {\n constructor(\n /**\n * extension config\n */\n readonly config: GraphQLConfig,\n\n /**\n * slot for registering graphql modules\n */\n private moduleSlot: SchemaSlot,\n\n /**\n * harmony context.\n */\n private context: Harmony,\n\n /**\n * logger extension.\n */\n readonly logger: Logger,\n\n private graphQLServerSlot: GraphQLServerSlot,\n\n /**\n * graphql pubsub. allows to emit events to clients.\n */\n private pubSubSlot: PubSubSlot\n ) {}\n\n get pubsub(): PubSubEngine {\n const pubSubSlots = this.pubSubSlot.values();\n if (pubSubSlots.length) return pubSubSlots[0];\n return new PubSub();\n }\n\n private modules = new Map<string, GraphQLModule>();\n\n /**\n * returns the schema for a specific aspect by its id.\n */\n getSchema(aspectId: string): Schema | undefined {\n const schemaOrFunc = this.moduleSlot.get(aspectId);\n if (!schemaOrFunc) return undefined;\n const schema = typeof schemaOrFunc === 'function' ? schemaOrFunc() : schemaOrFunc;\n return schema;\n }\n\n get execute() {\n return execute;\n }\n\n /**\n * get multiple schema by aspect ids.\n * used by the cloud.\n */\n getSchemas(aspectIds: string[]): Schema[] {\n return this.moduleSlot\n .toArray()\n .filter(([aspectId]) => {\n return aspectIds.includes(aspectId);\n })\n .map(([, schemaOrFunc]) => {\n return typeof schemaOrFunc === 'function' ? schemaOrFunc() : schemaOrFunc;\n });\n }\n\n async createServer(options: GraphQLServerOptions) {\n const { graphiql = true, disableIntrospection } = options;\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // TODO: @guy please consider to refactor to express extension.\n const app = options.app || express();\n if (!this.config.disableCors) {\n app.use(\n cors({\n origin(origin, callback) {\n callback(null, true);\n },\n credentials: true,\n })\n );\n }\n\n app.use(\n '/graphql',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n graphqlHTTP((request, res, params) => ({\n extensions: options?.extensions,\n customExecuteFn: options.customExecuteFn,\n customFormatErrorFn: options.customFormatErrorFn\n ? options.customFormatErrorFn\n : (err) => {\n this.logger.error('graphql got an error during running the following query:', params);\n this.logger.error('graphql error ', err);\n return Object.assign(err, {\n // @ts-ignore\n ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,\n // @ts-ignore\n HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code,\n });\n },\n schema,\n rootValue: request,\n graphiql,\n validationRules: disableIntrospection ? [NoIntrospection] : undefined,\n }))\n );\n\n const server = createServer(app);\n const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange;\n const subscriptionServerPort = await this.getPort(subscriptionsPort);\n const { port } = await this.createSubscription(options, subscriptionServerPort);\n this.proxySubscription(server, port);\n\n return server;\n }\n\n /**\n * register a new graphql server.\n */\n registerServer(server: GraphQLServer) {\n this.graphQLServerSlot.register(server);\n return this;\n }\n\n /**\n * register a pubsub client\n */\n registerPubSub(pubsub: PubSubEngine) {\n const pubSubSlots = this.pubSubSlot.toArray();\n if (pubSubSlots.length) throw new Error('can not register more then one pubsub provider');\n this.pubSubSlot.register(pubsub);\n return this;\n }\n\n /**\n * start a graphql server.\n */\n async listen(port?: number, server?: Server, app?: Express) {\n const serverPort = port || this.config.port;\n const subServer = server || (await this.createServer({ app }));\n\n subServer.listen(serverPort, () => {\n this.logger.info(`API Server over HTTP is now running on http://localhost:${serverPort}`);\n this.logger.info(\n `API Server over web socket with subscriptions is now running on ws://localhost:${serverPort}/${this.config.subscriptionsPath}`\n );\n });\n }\n\n /**\n * register a new graphql module.\n * @param schema a function that returns Schema. avoid passing the Schema directly, it's supported only for backward\n * compatibility but really bad for performance. it pulls the entire graphql library.\n */\n register(schema: Schema | (() => Schema)) {\n // const module = new GraphQLModule(schema);\n this.moduleSlot.register(schema);\n return this;\n }\n\n private async getPort(range: number[]) {\n const [from, to] = range;\n return Port.getPort(from, to);\n }\n\n /** create Subscription server with different port */\n\n private async createSubscription(options: GraphQLServerOptions, port: number) {\n // Create WebSocket listener server\n const websocketServer = createServer((request, response) => {\n response.writeHead(404);\n response.end();\n });\n\n // Bind it to port and start listening\n websocketServer.listen(port, () =>\n this.logger.debug(`Websocket Server is now running on http://localhost:${port}`)\n );\n\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const subServer = new SubscriptionServer(\n {\n execute,\n subscribe,\n schema,\n onConnect: options.onWsConnect,\n },\n {\n server: websocketServer,\n path: this.config.subscriptionsPath,\n }\n );\n return { subServer, port };\n }\n /** proxy ws Subscription server to avoid conflict with different websocket connections */\n\n private proxySubscription(server: Server, port: number) {\n const proxServer = httpProxy.createProxyServer();\n const subscriptionsPath = this.config.subscriptionsPath;\n server.on('upgrade', function (req, socket, head) {\n if (req.url === subscriptionsPath) {\n proxServer.ws(req, socket, head, { target: { host: 'localhost', port } });\n }\n });\n }\n\n private createRootModule(schemaSlot?: SchemaSlot) {\n const modules = this.buildModules(schemaSlot);\n\n return new GraphQLModule({\n imports: modules,\n });\n }\n\n private buildModules(schemaSlot?: SchemaSlot) {\n const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray();\n return schemaSlots.map(([extensionId, schemaOrFunc]) => {\n const schema = typeof schemaOrFunc === 'function' ? schemaOrFunc() : schemaOrFunc;\n const moduleDeps = this.getModuleDependencies(extensionId);\n\n const module = new GraphQLModule({\n typeDefs: schema.typeDefs,\n resolvers: schema.resolvers,\n schemaDirectives: schema.schemaDirectives,\n imports: moduleDeps,\n context: (session) => {\n return {\n ...session,\n verb: session?.headers?.['x-verb'] || Verb.READ,\n };\n },\n });\n\n this.modules.set(extensionId, module);\n\n return module;\n });\n }\n\n private getModuleDependencies(extensionId: string): GraphQLModule[] {\n const extension = this.context.extensions.get(extensionId);\n if (!extension) throw new Error(`aspect ${extensionId} was not found`);\n const deps = this.context.getDependencies(extension);\n const ids = deps.map((dep) => dep.id);\n\n return Array.from(this.modules.entries())\n .map(([depId, module]) => {\n const dep = ids.includes(depId);\n if (!dep) return undefined;\n return module;\n })\n .filter((module) => !!module);\n }\n\n static slots = [Slot.withType<Schema>(), Slot.withType<GraphQLServer>(), Slot.withType<PubSubSlot>()];\n\n static defaultConfig = {\n port: 4000,\n subscriptionsPortRange: [2000, 2100],\n disableCors: false,\n subscriptionsPath: '/subscriptions',\n };\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect];\n\n static async provider(\n [loggerFactory]: [LoggerMain],\n config: GraphQLConfig,\n [moduleSlot, graphQLServerSlot, pubSubSlot]: [SchemaSlot, GraphQLServerSlot, PubSubSlot],\n context: Harmony\n ) {\n const logger = loggerFactory.createLogger(GraphqlAspect.id);\n const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot);\n graphqlMain.registerPubSub(new PubSub());\n return graphqlMain;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlMain);\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,6BAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,4BAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,KAAA;EAAA,MAAAL,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Aa,CAACC,YAAY,CAACC,yBAAa,CAACP,EAAE,CAAC;IAC3D,MAAMQ,WAAW,GAAG,IAAIzI,WAAW,CAACE,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,UAAU,CAAC;IACvGkI,WAAW,CAAC9D,cAAc,CAAC,KAAI/D,8BAAM,EAAC,CAAC,CAAC;IACxC,OAAO6H,WAAW;EACpB;AACF;AAAC1I,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAAAlB,eAAA,CAnSYkB,WAAW,WA4QP,CAAC0I,eAAI,CAACC,QAAQ,CAAS,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAgB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAa,CAAC,CAAC;AAAA7J,eAAA,CA5Q1FkB,WAAW,mBA8QC;EACrBsE,IAAI,EAAE,IAAI;EACVH,sBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;EACpC3B,WAAW,EAAE,KAAK;EAClByC,iBAAiB,EAAE;AACrB,CAAC;AAAAnG,eAAA,CAnRUkB,WAAW,aAqRL4I,kBAAW;AAAA9J,eAAA,CArRjBkB,WAAW,kBAsRA,CAAC6I,sBAAY,CAAC;AAetCL,yBAAa,CAACM,UAAU,CAAC9I,WAAW,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_schema","data","require","_graphqlDisableIntrospection","_interopRequireDefault","_core","_cli","_harmony","_logger","_express","_expressGraphql","_toolboxNetwork","_graphql","_graphqlSubscriptions","_http","_httpProxy","_subscriptionsTransportWs","_cors","_createRemoteSchemas","_graphql2","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","Verb","exports","GraphqlMain","constructor","config","moduleSlot","context","logger","graphQLServerSlot","pubSubSlot","Map","pubsub","pubSubSlots","values","PubSub","getSchema","aspectId","schemaOrFunc","get","undefined","schema","execute","getSchemas","aspectIds","toArray","includes","map","createServer","options","graphiql","disableIntrospection","localSchema","createRootModule","schemaSlot","remoteSchemas","createRemoteSchemas","schemas","concat","x","mergeSchemas","app","express","disableCors","use","cors","origin","callback","credentials","batchingEnabled","enableBatching","json","req","res","next","method","Array","isArray","body","is","max","batchMax","status","errors","message","formatError","customFormatErrorFn","err","error","assign","ERR_CODE","originalError","name","HTTP_CODE","code","validationRules","NoIntrospection","specifiedRules","execFn","customExecuteFn","ops","results","Promise","all","op","query","document","parse","validationErrors","validate","result","rootValue","contextValue","variableValues","variables","operationName","Error","graphqlHTTP","request","params","extensions","server","subscriptionsPort","subscriptionsPortRange","subscriptionServerPort","getPort","port","createSubscription","proxySubscription","registerServer","register","registerPubSub","listen","serverPort","subServer","info","subscriptionsPath","range","from","to","Port","websocketServer","response","writeHead","end","debug","SubscriptionServer","subscribe","onConnect","onWsConnect","path","proxServer","httpProxy","createProxyServer","on","socket","head","url","ws","target","host","modules","buildModules","GraphQLModule","imports","schemaSlots","extensionId","moduleDeps","getModuleDependencies","module","typeDefs","resolvers","schemaDirectives","session","verb","headers","READ","set","extension","deps","getDependencies","ids","dep","id","entries","depId","provider","loggerFactory","createLogger","GraphqlAspect","graphqlMain","Slot","withType","MainRuntime","LoggerAspect","addRuntime"],"sources":["graphql.main.runtime.ts"],"sourcesContent":["import { mergeSchemas } from '@graphql-tools/schema';\nimport NoIntrospection from 'graphql-disable-introspection';\nimport { GraphQLModule } from '@graphql-modules/core';\nimport { MainRuntime } from '@teambit/cli';\nimport type { Harmony, SlotRegistry } from '@teambit/harmony';\nimport { Slot } from '@teambit/harmony';\nimport type { Logger, LoggerMain } from '@teambit/logger';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { Express } from 'express';\nimport express from 'express';\nimport { graphqlHTTP, type RequestInfo } from 'express-graphql';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { execute, parse, specifiedRules, subscribe, validate } from 'graphql';\nimport type { PubSubEngine } from 'graphql-subscriptions';\nimport { PubSub } from 'graphql-subscriptions';\nimport type { Server } from 'http';\nimport { createServer } from 'http';\nimport httpProxy from 'http-proxy';\nimport { SubscriptionServer } from 'subscriptions-transport-ws';\nimport cors from 'cors';\nimport type { GraphQLServer } from './graphql-server';\nimport { createRemoteSchemas } from './create-remote-schemas';\nimport { GraphqlAspect } from './graphql.aspect';\nimport type { Schema } from './schema';\n\nexport enum Verb {\n WRITE = 'write',\n READ = 'read',\n}\n\nexport type GraphQLConfig = {\n port: number;\n subscriptionsPortRange: number[];\n subscriptionsPath: string;\n disableCors?: boolean;\n enableBatching?: boolean;\n batchMax?: number;\n};\n\nexport type GraphQLServerSlot = SlotRegistry<GraphQLServer>;\n\nexport type SchemaSlot = SlotRegistry<Schema | (() => Schema)>;\n\nexport type PubSubSlot = SlotRegistry<PubSubEngine>;\n\nexport type GraphQLServerOptions = {\n schemaSlot?: SchemaSlot;\n app?: Express;\n graphiql?: boolean;\n disableIntrospection?: boolean;\n remoteSchemas?: GraphQLServer[];\n subscriptionsPortRange?: number[];\n onWsConnect?: Function;\n customExecuteFn?: (args: any) => Promise<any>;\n customFormatErrorFn?: (args: any) => any;\n extensions?: (info: RequestInfo) => Promise<any>;\n};\n\nexport class GraphqlMain {\n constructor(\n /**\n * extension config\n */\n readonly config: GraphQLConfig,\n\n /**\n * slot for registering graphql modules\n */\n private moduleSlot: SchemaSlot,\n\n /**\n * harmony context.\n */\n private context: Harmony,\n\n /**\n * logger extension.\n */\n readonly logger: Logger,\n\n private graphQLServerSlot: GraphQLServerSlot,\n\n /**\n * graphql pubsub. allows to emit events to clients.\n */\n private pubSubSlot: PubSubSlot\n ) {}\n\n get pubsub(): PubSubEngine {\n const pubSubSlots = this.pubSubSlot.values();\n if (pubSubSlots.length) return pubSubSlots[0];\n return new PubSub();\n }\n\n private modules = new Map<string, GraphQLModule>();\n\n /**\n * returns the schema for a specific aspect by its id.\n */\n getSchema(aspectId: string): Schema | undefined {\n const schemaOrFunc = this.moduleSlot.get(aspectId);\n if (!schemaOrFunc) return undefined;\n const schema = typeof schemaOrFunc === 'function' ? schemaOrFunc() : schemaOrFunc;\n return schema;\n }\n\n get execute() {\n return execute;\n }\n\n /**\n * get multiple schema by aspect ids.\n * used by the cloud.\n */\n getSchemas(aspectIds: string[]): Schema[] {\n return this.moduleSlot\n .toArray()\n .filter(([aspectId]) => {\n return aspectIds.includes(aspectId);\n })\n .map(([, schemaOrFunc]) => {\n return typeof schemaOrFunc === 'function' ? schemaOrFunc() : schemaOrFunc;\n });\n }\n\n async createServer(options: GraphQLServerOptions) {\n const { graphiql = true, disableIntrospection } = options;\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // TODO: @guy please consider to refactor to express extension.\n const app = options.app || express();\n if (!this.config.disableCors) {\n app.use(\n cors({\n origin(origin, callback) {\n callback(null, true);\n },\n credentials: true,\n })\n );\n }\n\n const batchingEnabled = this.config.enableBatching;\n\n if (batchingEnabled) {\n app.use('/graphql', express.json());\n app.use('/graphql', async (req, res, next) => {\n if (req.method !== 'POST') return next();\n if (!Array.isArray(req.body)) return next();\n if (!req.is('application/json')) return next();\n const max = this.config.batchMax ?? 20;\n if (req.body.length > max) {\n return res.status(413).json([{ errors: [{ message: `Batch size ${req.body.length} exceeds max ${max}` }] }]);\n }\n\n const formatError =\n options.customFormatErrorFn ??\n ((err: any) => {\n this.logger.error('graphql got an error during running the following query:', req.body);\n this.logger.error('graphql error ', err);\n return Object.assign(err, {\n // @ts-ignore\n ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,\n // @ts-ignore\n HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err?.originalError?.code,\n });\n });\n\n const validationRules = disableIntrospection ? [NoIntrospection] : specifiedRules;\n\n (req as any).res = res;\n\n const execFn = options.customExecuteFn ?? (execute as any);\n\n try {\n const ops = req.body as Array<{\n query?: string;\n variables?: Record<string, any>;\n operationName?: string;\n }>;\n\n const results = await Promise.all(\n ops.map(async (op) => {\n if (!op?.query || typeof op.query !== 'string') {\n return { errors: [{ message: 'Must provide query string.' }] };\n }\n\n try {\n const document = parse(op.query);\n\n const validationErrors = validate(schema, document, validationRules as any);\n if (validationErrors.length) {\n return { errors: validationErrors.map(formatError) };\n }\n\n const result = await execFn({\n schema,\n document,\n rootValue: req,\n contextValue: req,\n variableValues: op.variables,\n operationName: op.operationName,\n });\n\n if ((result as any)?.errors?.length) {\n return { ...(result as any), errors: (result as any).errors.map(formatError) };\n }\n\n return result;\n } catch (err: any) {\n this.logger.error('graphql batch error', err);\n const e = err instanceof Error ? err : new Error(err?.message ?? String(err));\n return { errors: [formatError(e)] };\n }\n })\n );\n\n return res.status(200).json(results);\n } catch (err) {\n return next(err);\n }\n });\n }\n\n app.use(\n '/graphql',\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n graphqlHTTP((request, res, params) => ({\n extensions: options?.extensions,\n customExecuteFn: options.customExecuteFn,\n customFormatErrorFn: options.customFormatErrorFn\n ? options.customFormatErrorFn\n : (err) => {\n this.logger.error('graphql got an error during running the following query:', params);\n this.logger.error('graphql error ', err);\n return Object.assign(err, {\n // @ts-ignore\n ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,\n // @ts-ignore\n HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err.originalError?.code,\n });\n },\n schema,\n rootValue: request,\n graphiql,\n validationRules: disableIntrospection ? [NoIntrospection] : undefined,\n }))\n );\n\n const server = createServer(app);\n const subscriptionsPort = options.subscriptionsPortRange || this.config.subscriptionsPortRange;\n const subscriptionServerPort = await this.getPort(subscriptionsPort);\n const { port } = await this.createSubscription(options, subscriptionServerPort);\n this.proxySubscription(server, port);\n\n return server;\n }\n\n /**\n * register a new graphql server.\n */\n registerServer(server: GraphQLServer) {\n this.graphQLServerSlot.register(server);\n return this;\n }\n\n /**\n * register a pubsub client\n */\n registerPubSub(pubsub: PubSubEngine) {\n const pubSubSlots = this.pubSubSlot.toArray();\n if (pubSubSlots.length) throw new Error('can not register more then one pubsub provider');\n this.pubSubSlot.register(pubsub);\n return this;\n }\n\n /**\n * start a graphql server.\n */\n async listen(port?: number, server?: Server, app?: Express) {\n const serverPort = port || this.config.port;\n const subServer = server || (await this.createServer({ app }));\n\n subServer.listen(serverPort, () => {\n this.logger.info(`API Server over HTTP is now running on http://localhost:${serverPort}`);\n this.logger.info(\n `API Server over web socket with subscriptions is now running on ws://localhost:${serverPort}/${this.config.subscriptionsPath}`\n );\n });\n }\n\n /**\n * register a new graphql module.\n * @param schema a function that returns Schema. avoid passing the Schema directly, it's supported only for backward\n * compatibility but really bad for performance. it pulls the entire graphql library.\n */\n register(schema: Schema | (() => Schema)) {\n // const module = new GraphQLModule(schema);\n this.moduleSlot.register(schema);\n return this;\n }\n\n private async getPort(range: number[]) {\n const [from, to] = range;\n return Port.getPort(from, to);\n }\n\n /** create Subscription server with different port */\n\n private async createSubscription(options: GraphQLServerOptions, port: number) {\n // Create WebSocket listener server\n const websocketServer = createServer((request, response) => {\n response.writeHead(404);\n response.end();\n });\n\n // Bind it to port and start listening\n websocketServer.listen(port, () =>\n this.logger.debug(`Websocket Server is now running on http://localhost:${port}`)\n );\n\n const localSchema = this.createRootModule(options.schemaSlot);\n const remoteSchemas = await createRemoteSchemas(options.remoteSchemas || this.graphQLServerSlot.values());\n const schemas = [localSchema.schema].concat(remoteSchemas).filter((x) => x);\n const schema = mergeSchemas({\n schemas,\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const subServer = new SubscriptionServer(\n {\n execute,\n subscribe,\n schema,\n onConnect: options.onWsConnect,\n },\n {\n server: websocketServer,\n path: this.config.subscriptionsPath,\n }\n );\n return { subServer, port };\n }\n /** proxy ws Subscription server to avoid conflict with different websocket connections */\n\n private proxySubscription(server: Server, port: number) {\n const proxServer = httpProxy.createProxyServer();\n const subscriptionsPath = this.config.subscriptionsPath;\n server.on('upgrade', function (req, socket, head) {\n if (req.url === subscriptionsPath) {\n proxServer.ws(req, socket, head, { target: { host: 'localhost', port } });\n }\n });\n }\n\n private createRootModule(schemaSlot?: SchemaSlot) {\n const modules = this.buildModules(schemaSlot);\n\n return new GraphQLModule({\n imports: modules,\n });\n }\n\n private buildModules(schemaSlot?: SchemaSlot) {\n const schemaSlots = schemaSlot ? schemaSlot.toArray() : this.moduleSlot.toArray();\n return schemaSlots.map(([extensionId, schemaOrFunc]) => {\n const schema = typeof schemaOrFunc === 'function' ? schemaOrFunc() : schemaOrFunc;\n const moduleDeps = this.getModuleDependencies(extensionId);\n\n const module = new GraphQLModule({\n typeDefs: schema.typeDefs,\n resolvers: schema.resolvers,\n schemaDirectives: schema.schemaDirectives,\n imports: moduleDeps,\n context: (session) => {\n return {\n ...session,\n verb: session?.headers?.['x-verb'] || Verb.READ,\n };\n },\n });\n\n this.modules.set(extensionId, module);\n\n return module;\n });\n }\n\n private getModuleDependencies(extensionId: string): GraphQLModule[] {\n const extension = this.context.extensions.get(extensionId);\n if (!extension) throw new Error(`aspect ${extensionId} was not found`);\n const deps = this.context.getDependencies(extension);\n const ids = deps.map((dep) => dep.id);\n\n return Array.from(this.modules.entries())\n .map(([depId, module]) => {\n const dep = ids.includes(depId);\n if (!dep) return undefined;\n return module;\n })\n .filter((module) => !!module);\n }\n\n static slots = [Slot.withType<Schema>(), Slot.withType<GraphQLServer>(), Slot.withType<PubSubSlot>()];\n\n static defaultConfig = {\n port: 4000,\n subscriptionsPortRange: [2000, 2100],\n disableCors: false,\n subscriptionsPath: '/subscriptions',\n enableBatching: false,\n batchMax: 20,\n };\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect];\n\n static async provider(\n [loggerFactory]: [LoggerMain],\n config: GraphQLConfig,\n [moduleSlot, graphQLServerSlot, pubSubSlot]: [SchemaSlot, GraphQLServerSlot, PubSubSlot],\n context: Harmony\n ) {\n const logger = loggerFactory.createLogger(GraphqlAspect.id);\n const graphqlMain = new GraphqlMain(config, moduleSlot, context, logger, graphQLServerSlot, pubSubSlot);\n graphqlMain.registerPubSub(new PubSub());\n return graphqlMain;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlMain);\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,6BAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,4BAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,KAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,IAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,SAAA;EAAA,MAAAR,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAO,QAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA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 -15,17 +15,24 @@ type ClientOptions = {
|
|
|
15
15
|
/** host extension id (workspace or scope). Used to configure the client */
|
|
16
16
|
host?: string;
|
|
17
17
|
};
|
|
18
|
+
export type GraphQLConfig = {
|
|
19
|
+
enableBatching?: boolean;
|
|
20
|
+
batchInterval?: number;
|
|
21
|
+
batchMax?: number;
|
|
22
|
+
};
|
|
18
23
|
export declare class GraphqlUI {
|
|
24
|
+
readonly config: GraphQLConfig;
|
|
25
|
+
constructor(config?: GraphQLConfig);
|
|
19
26
|
createClient(uri: string, { state, subscriptionUri, host }?: ClientOptions): ApolloClient<NormalizedCacheObject>;
|
|
20
27
|
createSsrClient({ serverUrl, headers }: {
|
|
21
28
|
serverUrl: string;
|
|
22
29
|
headers: any;
|
|
23
30
|
}): ApolloClient<NormalizedCacheObject>;
|
|
31
|
+
private createSsrClientBatched;
|
|
24
32
|
private createCache;
|
|
33
|
+
private readonly isMutation;
|
|
25
34
|
private createLink;
|
|
26
|
-
|
|
27
|
-
* get the graphQL provider
|
|
28
|
-
*/
|
|
35
|
+
private createLinkBatched;
|
|
29
36
|
getProvider: ({ client, children }: {
|
|
30
37
|
client: GraphQLClient<any>;
|
|
31
38
|
children: ReactNode;
|
|
@@ -34,6 +41,7 @@ export declare class GraphqlUI {
|
|
|
34
41
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
35
42
|
static dependencies: never[];
|
|
36
43
|
static slots: never[];
|
|
37
|
-
static
|
|
44
|
+
static defaultConfig: GraphQLConfig;
|
|
45
|
+
static provider(_: any, config: GraphQLConfig): Promise<GraphqlUI>;
|
|
38
46
|
}
|
|
39
47
|
export {};
|
|
@@ -18,6 +18,13 @@ function _ui() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
+
function _batchHttp() {
|
|
22
|
+
const data = require("@apollo/client/link/batch-http");
|
|
23
|
+
_batchHttp = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
21
28
|
function _client() {
|
|
22
29
|
const data = require("@apollo/client");
|
|
23
30
|
_client = function () {
|
|
@@ -39,6 +46,13 @@ function _error() {
|
|
|
39
46
|
};
|
|
40
47
|
return data;
|
|
41
48
|
}
|
|
49
|
+
function _utilities() {
|
|
50
|
+
const data = require("@apollo/client/utilities");
|
|
51
|
+
_utilities = function () {
|
|
52
|
+
return data;
|
|
53
|
+
};
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
42
56
|
function _crossFetch() {
|
|
43
57
|
const data = _interopRequireDefault(require("cross-fetch"));
|
|
44
58
|
_crossFetch = function () {
|
|
@@ -91,10 +105,12 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
91
105
|
* */
|
|
92
106
|
|
|
93
107
|
class GraphqlUI {
|
|
94
|
-
constructor() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
108
|
+
constructor(config = {}) {
|
|
109
|
+
this.config = config;
|
|
110
|
+
_defineProperty(this, "isMutation", op => {
|
|
111
|
+
const def = (0, _utilities().getMainDefinition)(op.query);
|
|
112
|
+
return def.kind === 'OperationDefinition' && def.operation === 'mutation';
|
|
113
|
+
});
|
|
98
114
|
_defineProperty(this, "getProvider", ({
|
|
99
115
|
client,
|
|
100
116
|
children
|
|
@@ -136,6 +152,12 @@ class GraphqlUI {
|
|
|
136
152
|
serverUrl,
|
|
137
153
|
headers
|
|
138
154
|
}) {
|
|
155
|
+
if (this.config.enableBatching) {
|
|
156
|
+
return this.createSsrClientBatched({
|
|
157
|
+
serverUrl,
|
|
158
|
+
headers
|
|
159
|
+
});
|
|
160
|
+
}
|
|
139
161
|
const link = _client().ApolloLink.from([(0, _error().onError)(_logging().logError), (0, _client().createHttpLink)({
|
|
140
162
|
credentials: 'include',
|
|
141
163
|
uri: serverUrl,
|
|
@@ -149,6 +171,31 @@ class GraphqlUI {
|
|
|
149
171
|
});
|
|
150
172
|
return client;
|
|
151
173
|
}
|
|
174
|
+
createSsrClientBatched({
|
|
175
|
+
serverUrl,
|
|
176
|
+
headers
|
|
177
|
+
}) {
|
|
178
|
+
const batchedHttpLink = new (_batchHttp().BatchHttpLink)({
|
|
179
|
+
uri: serverUrl,
|
|
180
|
+
credentials: 'include',
|
|
181
|
+
batchInterval: this.config.batchInterval,
|
|
182
|
+
batchMax: this.config.batchMax,
|
|
183
|
+
headers,
|
|
184
|
+
fetch: _crossFetch().default
|
|
185
|
+
});
|
|
186
|
+
const unbatchedHttpLink = new (_client().HttpLink)({
|
|
187
|
+
uri: serverUrl,
|
|
188
|
+
credentials: 'include',
|
|
189
|
+
headers,
|
|
190
|
+
fetch: _crossFetch().default
|
|
191
|
+
});
|
|
192
|
+
const httpLink = _client().ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
193
|
+
return new (_client().ApolloClient)({
|
|
194
|
+
ssrMode: true,
|
|
195
|
+
link: _client().ApolloLink.from([(0, _error().onError)(_logging().logError), httpLink]),
|
|
196
|
+
cache: this.createCache()
|
|
197
|
+
});
|
|
198
|
+
}
|
|
152
199
|
createCache({
|
|
153
200
|
state
|
|
154
201
|
} = {}) {
|
|
@@ -159,6 +206,11 @@ class GraphqlUI {
|
|
|
159
206
|
createLink(uri, {
|
|
160
207
|
subscriptionUri
|
|
161
208
|
} = {}) {
|
|
209
|
+
if (this.config.enableBatching) {
|
|
210
|
+
return this.createLinkBatched(uri, {
|
|
211
|
+
subscriptionUri
|
|
212
|
+
});
|
|
213
|
+
}
|
|
162
214
|
const httpLink = new (_client().HttpLink)({
|
|
163
215
|
credentials: 'include',
|
|
164
216
|
uri
|
|
@@ -173,15 +225,42 @@ class GraphqlUI {
|
|
|
173
225
|
const errorLogger = (0, _error().onError)(_logging().logError);
|
|
174
226
|
return _client().ApolloLink.from([errorLogger, hybridLink]);
|
|
175
227
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
228
|
+
createLinkBatched(uri, {
|
|
229
|
+
subscriptionUri
|
|
230
|
+
} = {}) {
|
|
231
|
+
const batchedHttpLink = new (_batchHttp().BatchHttpLink)({
|
|
232
|
+
uri,
|
|
233
|
+
credentials: 'include',
|
|
234
|
+
batchInterval: this.config.batchInterval,
|
|
235
|
+
batchMax: this.config.batchMax
|
|
236
|
+
});
|
|
237
|
+
const unbatchedHttpLink = new (_client().HttpLink)({
|
|
238
|
+
uri,
|
|
239
|
+
credentials: 'include'
|
|
240
|
+
});
|
|
241
|
+
const httpLink = _client().ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
242
|
+
const wsLink = subscriptionUri ? new (_ws().WebSocketLink)({
|
|
243
|
+
uri: subscriptionUri,
|
|
244
|
+
options: {
|
|
245
|
+
reconnect: true
|
|
246
|
+
}
|
|
247
|
+
}) : undefined;
|
|
248
|
+
const transport = wsLink ? (0, _createLink().createSplitLink)(httpLink, wsLink) : httpLink;
|
|
249
|
+
return _client().ApolloLink.from([(0, _error().onError)(_logging().logError), transport]);
|
|
250
|
+
}
|
|
251
|
+
static async provider(_, config) {
|
|
252
|
+
return new GraphqlUI(config);
|
|
179
253
|
}
|
|
180
254
|
}
|
|
181
255
|
exports.GraphqlUI = GraphqlUI;
|
|
182
256
|
_defineProperty(GraphqlUI, "runtime", _ui().UIRuntime);
|
|
183
257
|
_defineProperty(GraphqlUI, "dependencies", []);
|
|
184
258
|
_defineProperty(GraphqlUI, "slots", []);
|
|
259
|
+
_defineProperty(GraphqlUI, "defaultConfig", {
|
|
260
|
+
enableBatching: false,
|
|
261
|
+
batchInterval: 50,
|
|
262
|
+
batchMax: 20
|
|
263
|
+
});
|
|
185
264
|
_graphql().GraphqlAspect.addRuntime(GraphqlUI);
|
|
186
265
|
|
|
187
266
|
//# sourceMappingURL=graphql.ui.runtime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","data","_interopRequireDefault","require","_ui","_client","_ws","_error","_crossFetch","_createLink","_graphqlProvider","_graphql","_renderLifecycle","_logging","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphqlUI","constructor","client","children","createElement","GraphQLProvider","GraphqlRenderPlugins","createClient","uri","state","subscriptionUri","host","defaultOptions","query","fetchPolicy","watchQuery","mutate","undefined","ApolloClient","link","createLink","cache","createCache","createSsrClient","serverUrl","headers","ApolloLink","from","onError","logError","createHttpLink","credentials","fetch","crossFetch","ssrMode","InMemoryCache","restore","httpLink","HttpLink","subsLink","WebSocketLink","options","reconnect","hybridLink","createSplitLink","errorLogger","provider","graphqlUI","exports","UIRuntime","GraphqlAspect","addRuntime"],"sources":["graphql.ui.runtime.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React from 'react';\nimport { UIRuntime } from '@teambit/ui';\n\nimport { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client';\nimport type { DefaultOptions, NormalizedCacheObject } from '@apollo/client';\nimport { WebSocketLink } from '@apollo/client/link/ws';\nimport { onError } from '@apollo/client/link/error';\n\nimport crossFetch from 'cross-fetch';\n\nimport { createSplitLink } from './create-link';\nimport { GraphQLProvider } from './graphql-provider';\nimport { GraphqlAspect } from './graphql.aspect';\nimport { GraphqlRenderPlugins } from './render-lifecycle';\nimport { logError } from './logging';\n\n/**\n * Type of gql client.\n * Used to abstract Apollo client, so consumers could import the type from graphql.ui, and not have to depend on @apollo/client directly\n * */\nexport type GraphQLClient<T> = ApolloClient<T>;\n\ntype ClientOptions = {\n /** Preset in-memory cache with state (e.g. continue state from SSR) */\n state?: NormalizedCacheObject;\n /** endpoint for websocket connections */\n subscriptionUri?: string;\n /** host extension id (workspace or scope). Used to configure the client */\n host?: string;\n};\n\nexport class GraphqlUI {\n createClient(uri: string, { state, subscriptionUri, host }: ClientOptions = {}) {\n const defaultOptions: DefaultOptions | undefined =\n host === 'teambit.workspace/workspace'\n ? {\n query: {\n fetchPolicy: 'network-only',\n },\n watchQuery: {\n fetchPolicy: 'network-only',\n },\n mutate: {\n fetchPolicy: 'network-only',\n },\n }\n : undefined;\n const client = new ApolloClient({\n link: this.createLink(uri, { subscriptionUri }),\n cache: this.createCache({ state }),\n defaultOptions,\n });\n\n return client;\n }\n\n createSsrClient({ serverUrl, headers }: { serverUrl: string; headers: any }) {\n const link = ApolloLink.from([\n onError(logError),\n createHttpLink({\n credentials: 'include',\n uri: serverUrl,\n headers,\n fetch: crossFetch,\n }),\n ]);\n\n const client = new ApolloClient({\n ssrMode: true,\n link,\n cache: this.createCache(),\n });\n\n return client;\n }\n\n private createCache({ state }: { state?: NormalizedCacheObject } = {}) {\n const cache = new InMemoryCache();\n\n if (state) cache.restore(state);\n\n return cache;\n }\n\n private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {\n const httpLink = new HttpLink({ credentials: 'include', uri });\n const subsLink = subscriptionUri\n ? new WebSocketLink({\n uri: subscriptionUri,\n options: { reconnect: true },\n })\n : undefined;\n\n const hybridLink = subsLink ? createSplitLink(httpLink, subsLink) : httpLink;\n const errorLogger = onError(logError);\n\n return ApolloLink.from([errorLogger, hybridLink]);\n }\n\n /**\n * get the graphQL provider\n */\n getProvider = ({ client, children }: { client: GraphQLClient<any>; children: ReactNode }) => {\n return <GraphQLProvider client={client}>{children}</GraphQLProvider>;\n };\n\n readonly renderPlugins = new GraphqlRenderPlugins(this);\n\n static runtime = UIRuntime;\n static dependencies = [];\n static slots = [];\n\n static async provider() {\n const graphqlUI = new GraphqlUI();\n\n return graphqlUI;\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlUI);\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,GAAA,YAAAA,CAA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GAAG,CAAC,CAAC,EAAE;IACtF,MAAM2B,QAAQ,GAAG,KAAIC,kBAAQ,EAAC;MAAEP,WAAW,EAAE,SAAS;MAAEvB;IAAI,CAAC,CAAC;IAC9D,MAAM+B,QAAQ,GAAG7B,eAAe,GAC5B,KAAI8B,mBAAa,EAAC;MAChBhC,GAAG,EAAEE,eAAe;MACpB+B,OAAO,EAAE;QAAEC,SAAS,EAAE;MAAK;IAC7B,CAAC,CAAC,GACFzB,SAAS;IAEb,MAAM0B,UAAU,GAAGJ,QAAQ,GAAG,IAAAK,6BAAe,EAACP,QAAQ,EAAEE,QAAQ,CAAC,GAAGF,QAAQ;IAC5E,MAAMQ,WAAW,GAAG,IAAAjB,gBAAO,EAACC,mBAAQ,CAAC;IAErC,OAAOH,oBAAU,CAACC,IAAI,CAAC,CAACkB,WAAW,EAAEF,UAAU,CAAC,CAAC;EACnD;EAeA,aAAaG,QAAQA,CAAA,EAAG;IACtB,MAAMC,SAAS,GAAG,IAAI/C,SAAS,CAAC,CAAC;IAEjC,OAAO+C,SAAS;EAClB;AACF;AAACC,OAAA,CAAAhD,SAAA,GAAAA,SAAA;AAAAlB,eAAA,CAtFYkB,SAAS,aA6EHiD,eAAS;AAAAnE,eAAA,CA7EfkB,SAAS,kBA8EE,EAAE;AAAAlB,eAAA,CA9EbkB,SAAS,WA+EL,EAAE;AASnBkD,wBAAa,CAACC,UAAU,CAACnD,SAAS,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_react","data","_interopRequireDefault","require","_ui","_batchHttp","_client","_ws","_error","_utilities","_crossFetch","_createLink","_graphqlProvider","_graphql","_renderLifecycle","_logging","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","GraphqlUI","constructor","config","op","def","getMainDefinition","query","kind","operation","client","children","createElement","GraphQLProvider","GraphqlRenderPlugins","createClient","uri","state","subscriptionUri","host","defaultOptions","fetchPolicy","watchQuery","mutate","undefined","ApolloClient","link","createLink","cache","createCache","createSsrClient","serverUrl","headers","enableBatching","createSsrClientBatched","ApolloLink","from","onError","logError","createHttpLink","credentials","fetch","crossFetch","ssrMode","batchedHttpLink","BatchHttpLink","batchInterval","batchMax","unbatchedHttpLink","HttpLink","httpLink","split","isMutation","InMemoryCache","restore","createLinkBatched","subsLink","WebSocketLink","options","reconnect","hybridLink","createSplitLink","errorLogger","wsLink","transport","provider","_","exports","UIRuntime","GraphqlAspect","addRuntime"],"sources":["graphql.ui.runtime.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport React from 'react';\nimport { UIRuntime } from '@teambit/ui';\nimport { BatchHttpLink } from '@apollo/client/link/batch-http';\nimport { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client';\nimport type { DefaultOptions, NormalizedCacheObject, Operation } from '@apollo/client';\nimport { WebSocketLink } from '@apollo/client/link/ws';\nimport { onError } from '@apollo/client/link/error';\nimport { getMainDefinition } from '@apollo/client/utilities';\nimport type { OperationDefinitionNode } from 'graphql';\n\nimport crossFetch from 'cross-fetch';\n\nimport { createSplitLink } from './create-link';\nimport { GraphQLProvider } from './graphql-provider';\nimport { GraphqlAspect } from './graphql.aspect';\nimport { GraphqlRenderPlugins } from './render-lifecycle';\nimport { logError } from './logging';\n\n/**\n * Type of gql client.\n * Used to abstract Apollo client, so consumers could import the type from graphql.ui, and not have to depend on @apollo/client directly\n * */\nexport type GraphQLClient<T> = ApolloClient<T>;\n\ntype ClientOptions = {\n /** Preset in-memory cache with state (e.g. continue state from SSR) */\n state?: NormalizedCacheObject;\n /** endpoint for websocket connections */\n subscriptionUri?: string;\n /** host extension id (workspace or scope). Used to configure the client */\n host?: string;\n};\n\nexport type GraphQLConfig = {\n enableBatching?: boolean;\n batchInterval?: number;\n batchMax?: number;\n};\n\nexport class GraphqlUI {\n constructor(readonly config: GraphQLConfig = {}) {}\n\n createClient(uri: string, { state, subscriptionUri, host }: ClientOptions = {}) {\n const defaultOptions: DefaultOptions | undefined =\n host === 'teambit.workspace/workspace'\n ? {\n query: {\n fetchPolicy: 'network-only',\n },\n watchQuery: {\n fetchPolicy: 'network-only',\n },\n mutate: {\n fetchPolicy: 'network-only',\n },\n }\n : undefined;\n const client = new ApolloClient({\n link: this.createLink(uri, { subscriptionUri }),\n cache: this.createCache({ state }),\n defaultOptions,\n });\n\n return client;\n }\n\n createSsrClient({ serverUrl, headers }: { serverUrl: string; headers: any }) {\n if (this.config.enableBatching) {\n return this.createSsrClientBatched({ serverUrl, headers });\n }\n const link = ApolloLink.from([\n onError(logError),\n createHttpLink({\n credentials: 'include',\n uri: serverUrl,\n headers,\n fetch: crossFetch,\n }),\n ]);\n\n const client = new ApolloClient({\n ssrMode: true,\n link,\n cache: this.createCache(),\n });\n\n return client;\n }\n\n private createSsrClientBatched({ serverUrl, headers }: { serverUrl: string; headers: any }) {\n const batchedHttpLink = new BatchHttpLink({\n uri: serverUrl,\n credentials: 'include',\n batchInterval: this.config.batchInterval,\n batchMax: this.config.batchMax,\n headers,\n fetch: crossFetch,\n });\n\n const unbatchedHttpLink = new HttpLink({\n uri: serverUrl,\n credentials: 'include',\n headers,\n fetch: crossFetch,\n });\n\n const httpLink = ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);\n\n return new ApolloClient({\n ssrMode: true,\n link: ApolloLink.from([onError(logError), httpLink]),\n cache: this.createCache(),\n });\n }\n\n private createCache({ state }: { state?: NormalizedCacheObject } = {}) {\n const cache = new InMemoryCache();\n\n if (state) cache.restore(state);\n\n return cache;\n }\n\n private readonly isMutation = (op: Operation) => {\n const def = getMainDefinition(op.query) as OperationDefinitionNode;\n return def.kind === 'OperationDefinition' && def.operation === 'mutation';\n };\n\n private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {\n if (this.config.enableBatching) {\n return this.createLinkBatched(uri, { subscriptionUri });\n }\n const httpLink = new HttpLink({ credentials: 'include', uri });\n const subsLink = subscriptionUri\n ? new WebSocketLink({\n uri: subscriptionUri,\n options: { reconnect: true },\n })\n : undefined;\n\n const hybridLink = subsLink ? createSplitLink(httpLink, subsLink) : httpLink;\n const errorLogger = onError(logError);\n\n return ApolloLink.from([errorLogger, hybridLink]);\n }\n\n private createLinkBatched(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {\n const batchedHttpLink = new BatchHttpLink({\n uri,\n credentials: 'include',\n batchInterval: this.config.batchInterval,\n batchMax: this.config.batchMax,\n });\n\n const unbatchedHttpLink = new HttpLink({\n uri,\n credentials: 'include',\n });\n\n const httpLink = ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);\n\n const wsLink = subscriptionUri\n ? new WebSocketLink({ uri: subscriptionUri, options: { reconnect: true } })\n : undefined;\n\n const transport = wsLink ? createSplitLink(httpLink, wsLink) : httpLink;\n\n return ApolloLink.from([onError(logError), transport]);\n }\n\n getProvider = ({ client, children }: { client: GraphQLClient<any>; children: ReactNode }) => {\n return <GraphQLProvider client={client}>{children}</GraphQLProvider>;\n };\n\n readonly renderPlugins = new GraphqlRenderPlugins(this);\n\n static runtime = UIRuntime;\n static dependencies = [];\n static slots = [];\n\n static defaultConfig: GraphQLConfig = {\n enableBatching: false,\n batchInterval: 50,\n batchMax: 20,\n };\n\n static async provider(_, config: GraphQLConfig) {\n return new GraphqlUI(config);\n }\n}\n\nGraphqlAspect.addRuntime(GraphqlUI);\n"],"mappings":";;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,IAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,GAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,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,GAAGf,oBAAU,CAACgB,KAAK,CAAC,IAAI,CAACC,UAAU,EAAEJ,iBAAiB,EAAEJ,eAAe,CAAC;IAEtF,MAAMmB,MAAM,GAAG7C,eAAe,GAC1B,KAAIuC,mBAAa,EAAC;MAAEzC,GAAG,EAAEE,eAAe;MAAEwC,OAAO,EAAE;QAAEC,SAAS,EAAE;MAAK;IAAE,CAAC,CAAC,GACzEnC,SAAS;IAEb,MAAMwC,SAAS,GAAGD,MAAM,GAAG,IAAAF,6BAAe,EAACX,QAAQ,EAAEa,MAAM,CAAC,GAAGb,QAAQ;IAEvE,OAAOf,oBAAU,CAACC,IAAI,CAAC,CAAC,IAAAC,gBAAO,EAACC,mBAAQ,CAAC,EAAE0B,SAAS,CAAC,CAAC;EACxD;EAkBA,aAAaC,QAAQA,CAACC,CAAC,EAAE/D,MAAqB,EAAE;IAC9C,OAAO,IAAIF,SAAS,CAACE,MAAM,CAAC;EAC9B;AACF;AAACgE,OAAA,CAAAlE,SAAA,GAAAA,SAAA;AAAAlB,eAAA,CAtJYkB,SAAS,aAyIHmE,eAAS;AAAArF,eAAA,CAzIfkB,SAAS,kBA0IE,EAAE;AAAAlB,eAAA,CA1IbkB,SAAS,WA2IL,EAAE;AAAAlB,eAAA,CA3INkB,SAAS,mBA6IkB;EACpCgC,cAAc,EAAE,KAAK;EACrBa,aAAa,EAAE,EAAE;EACjBC,QAAQ,EAAE;AACZ,CAAC;AAOHsB,wBAAa,CAACC,UAAU,CAACrE,SAAS,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_graphql@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_graphql@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_graphql@1.0.866/dist/graphql.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_graphql@1.0.866/dist/graphql.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/graphql.ui.runtime.tsx
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { UIRuntime } from '@teambit/ui';
|
|
4
|
-
|
|
4
|
+
import { BatchHttpLink } from '@apollo/client/link/batch-http';
|
|
5
5
|
import { InMemoryCache, ApolloClient, ApolloLink, HttpLink, createHttpLink } from '@apollo/client';
|
|
6
|
-
import type { DefaultOptions, NormalizedCacheObject } from '@apollo/client';
|
|
6
|
+
import type { DefaultOptions, NormalizedCacheObject, Operation } from '@apollo/client';
|
|
7
7
|
import { WebSocketLink } from '@apollo/client/link/ws';
|
|
8
8
|
import { onError } from '@apollo/client/link/error';
|
|
9
|
+
import { getMainDefinition } from '@apollo/client/utilities';
|
|
10
|
+
import type { OperationDefinitionNode } from 'graphql';
|
|
9
11
|
|
|
10
12
|
import crossFetch from 'cross-fetch';
|
|
11
13
|
|
|
@@ -30,7 +32,15 @@ type ClientOptions = {
|
|
|
30
32
|
host?: string;
|
|
31
33
|
};
|
|
32
34
|
|
|
35
|
+
export type GraphQLConfig = {
|
|
36
|
+
enableBatching?: boolean;
|
|
37
|
+
batchInterval?: number;
|
|
38
|
+
batchMax?: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
33
41
|
export class GraphqlUI {
|
|
42
|
+
constructor(readonly config: GraphQLConfig = {}) {}
|
|
43
|
+
|
|
34
44
|
createClient(uri: string, { state, subscriptionUri, host }: ClientOptions = {}) {
|
|
35
45
|
const defaultOptions: DefaultOptions | undefined =
|
|
36
46
|
host === 'teambit.workspace/workspace'
|
|
@@ -56,6 +66,9 @@ export class GraphqlUI {
|
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
createSsrClient({ serverUrl, headers }: { serverUrl: string; headers: any }) {
|
|
69
|
+
if (this.config.enableBatching) {
|
|
70
|
+
return this.createSsrClientBatched({ serverUrl, headers });
|
|
71
|
+
}
|
|
59
72
|
const link = ApolloLink.from([
|
|
60
73
|
onError(logError),
|
|
61
74
|
createHttpLink({
|
|
@@ -75,6 +88,32 @@ export class GraphqlUI {
|
|
|
75
88
|
return client;
|
|
76
89
|
}
|
|
77
90
|
|
|
91
|
+
private createSsrClientBatched({ serverUrl, headers }: { serverUrl: string; headers: any }) {
|
|
92
|
+
const batchedHttpLink = new BatchHttpLink({
|
|
93
|
+
uri: serverUrl,
|
|
94
|
+
credentials: 'include',
|
|
95
|
+
batchInterval: this.config.batchInterval,
|
|
96
|
+
batchMax: this.config.batchMax,
|
|
97
|
+
headers,
|
|
98
|
+
fetch: crossFetch,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const unbatchedHttpLink = new HttpLink({
|
|
102
|
+
uri: serverUrl,
|
|
103
|
+
credentials: 'include',
|
|
104
|
+
headers,
|
|
105
|
+
fetch: crossFetch,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const httpLink = ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
109
|
+
|
|
110
|
+
return new ApolloClient({
|
|
111
|
+
ssrMode: true,
|
|
112
|
+
link: ApolloLink.from([onError(logError), httpLink]),
|
|
113
|
+
cache: this.createCache(),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
78
117
|
private createCache({ state }: { state?: NormalizedCacheObject } = {}) {
|
|
79
118
|
const cache = new InMemoryCache();
|
|
80
119
|
|
|
@@ -83,7 +122,15 @@ export class GraphqlUI {
|
|
|
83
122
|
return cache;
|
|
84
123
|
}
|
|
85
124
|
|
|
125
|
+
private readonly isMutation = (op: Operation) => {
|
|
126
|
+
const def = getMainDefinition(op.query) as OperationDefinitionNode;
|
|
127
|
+
return def.kind === 'OperationDefinition' && def.operation === 'mutation';
|
|
128
|
+
};
|
|
129
|
+
|
|
86
130
|
private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {
|
|
131
|
+
if (this.config.enableBatching) {
|
|
132
|
+
return this.createLinkBatched(uri, { subscriptionUri });
|
|
133
|
+
}
|
|
87
134
|
const httpLink = new HttpLink({ credentials: 'include', uri });
|
|
88
135
|
const subsLink = subscriptionUri
|
|
89
136
|
? new WebSocketLink({
|
|
@@ -98,9 +145,30 @@ export class GraphqlUI {
|
|
|
98
145
|
return ApolloLink.from([errorLogger, hybridLink]);
|
|
99
146
|
}
|
|
100
147
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
148
|
+
private createLinkBatched(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {
|
|
149
|
+
const batchedHttpLink = new BatchHttpLink({
|
|
150
|
+
uri,
|
|
151
|
+
credentials: 'include',
|
|
152
|
+
batchInterval: this.config.batchInterval,
|
|
153
|
+
batchMax: this.config.batchMax,
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
const unbatchedHttpLink = new HttpLink({
|
|
157
|
+
uri,
|
|
158
|
+
credentials: 'include',
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const httpLink = ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
162
|
+
|
|
163
|
+
const wsLink = subscriptionUri
|
|
164
|
+
? new WebSocketLink({ uri: subscriptionUri, options: { reconnect: true } })
|
|
165
|
+
: undefined;
|
|
166
|
+
|
|
167
|
+
const transport = wsLink ? createSplitLink(httpLink, wsLink) : httpLink;
|
|
168
|
+
|
|
169
|
+
return ApolloLink.from([onError(logError), transport]);
|
|
170
|
+
}
|
|
171
|
+
|
|
104
172
|
getProvider = ({ client, children }: { client: GraphQLClient<any>; children: ReactNode }) => {
|
|
105
173
|
return <GraphQLProvider client={client}>{children}</GraphQLProvider>;
|
|
106
174
|
};
|
|
@@ -111,10 +179,14 @@ export class GraphqlUI {
|
|
|
111
179
|
static dependencies = [];
|
|
112
180
|
static slots = [];
|
|
113
181
|
|
|
114
|
-
static
|
|
115
|
-
|
|
182
|
+
static defaultConfig: GraphQLConfig = {
|
|
183
|
+
enableBatching: false,
|
|
184
|
+
batchInterval: 50,
|
|
185
|
+
batchMax: 20,
|
|
186
|
+
};
|
|
116
187
|
|
|
117
|
-
|
|
188
|
+
static async provider(_, config: GraphQLConfig) {
|
|
189
|
+
return new GraphqlUI(config);
|
|
118
190
|
}
|
|
119
191
|
}
|
|
120
192
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/graphql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.866",
|
|
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.866"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@graphql-modules/core": "0.7.17",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@teambit/logger": "0.0.1390",
|
|
36
36
|
"@teambit/toolbox.network.get-port": "1.0.18",
|
|
37
37
|
"@teambit/ui-foundation.ui.is-browser": "0.0.500",
|
|
38
|
-
"@teambit/ui": "1.0.
|
|
38
|
+
"@teambit/ui": "1.0.866"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/cors": "2.8.10",
|