@teambit/graphql 1.0.1080 → 1.0.1081
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/graphql.main.runtime.d.ts +8 -0
- package/dist/graphql.main.runtime.js +68 -68
- package/dist/graphql.main.runtime.js.map +1 -1
- package/dist/graphql.ui.runtime.d.ts +8 -3
- package/dist/graphql.ui.runtime.js +31 -57
- package/dist/graphql.ui.runtime.js.map +1 -1
- package/dist/{preview-1785267101230.js → preview-1785278532531.js} +2 -2
- package/graphql.ui.runtime.tsx +38 -63
- package/package.json +6 -6
|
@@ -16,7 +16,15 @@ export type GraphQLConfig = {
|
|
|
16
16
|
subscriptionsPortRange: number[];
|
|
17
17
|
subscriptionsPath: string;
|
|
18
18
|
disableCors?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* master switch for accepting batched request bodies, off by default (a workspace opts in, matching
|
|
21
|
+
* the client's `enableBatching`). When disabled, a batched (array) body is not processed as a batch.
|
|
22
|
+
*/
|
|
19
23
|
enableBatching?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* cap on the number of operations in a single batched request body. requests over this size
|
|
26
|
+
* are rejected with HTTP 413.
|
|
27
|
+
*/
|
|
20
28
|
batchMax?: number;
|
|
21
29
|
};
|
|
22
30
|
export type GraphQLServerSlot = SlotRegistry<GraphQLServer>;
|
|
@@ -215,80 +215,80 @@ class GraphqlMain {
|
|
|
215
215
|
credentials: true
|
|
216
216
|
}));
|
|
217
217
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
}]
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
218
|
+
app.use('/graphql', _express().default.json());
|
|
219
|
+
app.use('/graphql', async (req, res, next) => {
|
|
220
|
+
if (req.method !== 'POST') return next();
|
|
221
|
+
if (!Array.isArray(req.body)) return next();
|
|
222
|
+
// batching disabled (default) → don't process array bodies as a batch; matches the client, which
|
|
223
|
+
// won't send batches unless the workspace opted in via `enableBatching`.
|
|
224
|
+
if (!this.config.enableBatching) return next();
|
|
225
|
+
if (!req.is('application/json')) return next();
|
|
226
|
+
const max = this.config.batchMax ?? 20;
|
|
227
|
+
if (req.body.length > max) {
|
|
228
|
+
return res.status(413).json([{
|
|
229
|
+
errors: [{
|
|
230
|
+
message: `Batch size ${req.body.length} exceeds max ${max}`
|
|
231
|
+
}]
|
|
232
|
+
}]);
|
|
233
|
+
}
|
|
234
|
+
const formatError = options.customFormatErrorFn ?? (err => {
|
|
235
|
+
this.logger.error('graphql got an error during running the following query:', req.body);
|
|
236
|
+
this.logger.error('graphql error ', err);
|
|
237
|
+
return Object.assign(err, {
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
ERR_CODE: err?.originalError?.errors?.[0].ERR_CODE || err.originalError?.constructor?.name,
|
|
240
|
+
// @ts-ignore
|
|
241
|
+
HTTP_CODE: err?.originalError?.errors?.[0].HTTP_CODE || err?.originalError?.code
|
|
242
242
|
});
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
243
|
+
});
|
|
244
|
+
const validationRules = disableIntrospection ? [_graphqlDisableIntrospection().default] : _graphql().specifiedRules;
|
|
245
|
+
req.res = res;
|
|
246
|
+
const execFn = options.customExecuteFn ?? _graphql().execute;
|
|
247
|
+
try {
|
|
248
|
+
const ops = req.body;
|
|
249
|
+
const results = await Promise.all(ops.map(async op => {
|
|
250
|
+
if (!op?.query || typeof op.query !== 'string') {
|
|
251
|
+
return {
|
|
252
|
+
errors: [{
|
|
253
|
+
message: 'Must provide query string.'
|
|
254
|
+
}]
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
try {
|
|
258
|
+
const document = (0, _graphql().parse)(op.query);
|
|
259
|
+
const validationErrors = (0, _graphql().validate)(schema, document, validationRules);
|
|
260
|
+
if (validationErrors.length) {
|
|
250
261
|
return {
|
|
251
|
-
errors:
|
|
252
|
-
message: 'Must provide query string.'
|
|
253
|
-
}]
|
|
262
|
+
errors: validationErrors.map(formatError)
|
|
254
263
|
};
|
|
255
264
|
}
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
rootValue: req,
|
|
268
|
-
contextValue: req,
|
|
269
|
-
variableValues: op.variables,
|
|
270
|
-
operationName: op.operationName
|
|
265
|
+
const result = await execFn({
|
|
266
|
+
schema,
|
|
267
|
+
document,
|
|
268
|
+
rootValue: req,
|
|
269
|
+
contextValue: req,
|
|
270
|
+
variableValues: op.variables,
|
|
271
|
+
operationName: op.operationName
|
|
272
|
+
});
|
|
273
|
+
if (result?.errors?.length) {
|
|
274
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
275
|
+
errors: result.errors.map(formatError)
|
|
271
276
|
});
|
|
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
277
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
278
|
+
return result;
|
|
279
|
+
} catch (err) {
|
|
280
|
+
this.logger.error('graphql batch error', err);
|
|
281
|
+
const e = err instanceof Error ? err : new Error(err?.message ?? String(err));
|
|
282
|
+
return {
|
|
283
|
+
errors: [formatError(e)]
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
}));
|
|
287
|
+
return res.status(200).json(results);
|
|
288
|
+
} catch (err) {
|
|
289
|
+
return next(err);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
292
|
app.use('/graphql',
|
|
293
293
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
294
294
|
(0, _expressGraphql().graphqlHTTP)((request, res, params) => ({
|
|
@@ -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","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;EAA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O,WAAW,GAAG,IAAIvK,WAAW,CAACE,MAAM,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,UAAU,CAAC;IACvGgK,WAAW,CAAC3D,cAAc,CAAC,KAAIhG,8BAAM,EAAC,CAAC,CAAC;IACxC,OAAO2J,WAAW;EACpB;AACF;AAACxK,OAAA,CAAAC,WAAA,GAAAA,WAAA;AAAAlB,eAAA,CAvXYkB,WAAW,WA8VP,CAACwK,eAAI,CAACC,QAAQ,CAAS,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAgB,CAAC,EAAED,eAAI,CAACC,QAAQ,CAAa,CAAC,CAAC;AAAA3L,eAAA,CA9V1FkB,WAAW,mBAgWC;EACrBuG,IAAI,EAAE,IAAI;EACVH,sBAAsB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;EACpC5D,WAAW,EAAE,KAAK;EAClByE,iBAAiB,EAAE,gBAAgB;EACnClE,cAAc,EAAE,KAAK;EACrBW,QAAQ,EAAE;AACZ,CAAC;AAAA5E,eAAA,CAvWUkB,WAAW,aAyWL0K,kBAAW;AAAA5L,eAAA,CAzWjBkB,WAAW,kBA0WA,CAAC2K,sBAAY,CAAC;AAetCL,yBAAa,CAACM,UAAU,CAAC5K,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","json","req","res","next","method","Array","isArray","body","enableBatching","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 /**\n * master switch for accepting batched request bodies, off by default (a workspace opts in, matching\n * the client's `enableBatching`). When disabled, a batched (array) body is not processed as a batch.\n */\n enableBatching?: boolean;\n /**\n * cap on the number of operations in a single batched request body. requests over this size\n * are rejected with HTTP 413.\n */\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 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 // batching disabled (default) → don't process array bodies as a batch; matches the client, which\n // won't send batches unless the workspace opted in via `enableBatching`.\n if (!this.config.enableBatching) 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 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;E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kB,WAAW,aAwWLyK,kBAAW;AAAA3L,eAAA,CAxWjBkB,WAAW,kBAyWA,CAAC0K,sBAAY,CAAC;AAetCL,yBAAa,CAACM,UAAU,CAAC3K,WAAW,CAAC","ignoreList":[]}
|
|
@@ -17,6 +17,13 @@ type ClientOptions = {
|
|
|
17
17
|
host?: string;
|
|
18
18
|
};
|
|
19
19
|
export type GraphQLConfig = {
|
|
20
|
+
/**
|
|
21
|
+
* master switch for request batching, off by default (a workspace opts in). When enabled, batching is
|
|
22
|
+
* still *per-operation opt-in*: only Apollo operations that set `context: { batch: true }` are coalesced
|
|
23
|
+
* via BatchHttpLink; everything else goes through a plain HttpLink. When disabled (the default) NO
|
|
24
|
+
* operation batches regardless of its context — a global opt-out for the whole workspace. Mutations
|
|
25
|
+
* never batch. tune the batching window/cap via the fields below.
|
|
26
|
+
*/
|
|
20
27
|
enableBatching?: boolean;
|
|
21
28
|
batchInterval?: number;
|
|
22
29
|
batchMax?: number;
|
|
@@ -29,11 +36,9 @@ export declare class GraphqlUI {
|
|
|
29
36
|
serverUrl: string;
|
|
30
37
|
headers: any;
|
|
31
38
|
}): ApolloClient<NormalizedCacheObject>;
|
|
32
|
-
private createSsrClientBatched;
|
|
33
39
|
private createCache;
|
|
34
|
-
private readonly
|
|
40
|
+
private readonly shouldBatch;
|
|
35
41
|
private createLink;
|
|
36
|
-
private createLinkBatched;
|
|
37
42
|
getProvider: ({ client, children }: {
|
|
38
43
|
client: GraphQLClient<any>;
|
|
39
44
|
children: ReactNode;
|
|
@@ -96,6 +96,8 @@ function _logging() {
|
|
|
96
96
|
return data;
|
|
97
97
|
}
|
|
98
98
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
99
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
100
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
99
101
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
100
102
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
101
103
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -107,9 +109,13 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
107
109
|
class GraphqlUI {
|
|
108
110
|
constructor(config = {}) {
|
|
109
111
|
this.config = config;
|
|
110
|
-
|
|
112
|
+
// batch only when the workspace enabled batching (`enableBatching`, default off) AND the operation
|
|
113
|
+
// opted in via `context: { batch: true }`. mutations never batch.
|
|
114
|
+
_defineProperty(this, "shouldBatch", op => {
|
|
115
|
+
if (!this.config.enableBatching) return false;
|
|
111
116
|
const def = (0, _utilities().getMainDefinition)(op.query);
|
|
112
|
-
|
|
117
|
+
if (def.kind === 'OperationDefinition' && def.operation === 'mutation') return false;
|
|
118
|
+
return op.getContext().batch === true;
|
|
113
119
|
});
|
|
114
120
|
_defineProperty(this, "getProvider", ({
|
|
115
121
|
client,
|
|
@@ -152,30 +158,13 @@ class GraphqlUI {
|
|
|
152
158
|
serverUrl,
|
|
153
159
|
headers
|
|
154
160
|
}) {
|
|
155
|
-
|
|
156
|
-
return this.createSsrClientBatched({
|
|
157
|
-
serverUrl,
|
|
158
|
-
headers
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
const link = _client().ApolloLink.from([(0, _error().onError)(_logging().logError), (0, _client().createHttpLink)({
|
|
162
|
-
credentials: 'include',
|
|
161
|
+
const httpLink = new (_client().HttpLink)({
|
|
163
162
|
uri: serverUrl,
|
|
163
|
+
credentials: 'include',
|
|
164
164
|
headers,
|
|
165
165
|
fetch: _crossFetch().default
|
|
166
|
-
})]);
|
|
167
|
-
const client = new (_client().ApolloClient)({
|
|
168
|
-
ssrMode: true,
|
|
169
|
-
link,
|
|
170
|
-
cache: this.createCache()
|
|
171
166
|
});
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
createSsrClientBatched({
|
|
175
|
-
serverUrl,
|
|
176
|
-
headers
|
|
177
|
-
}) {
|
|
178
|
-
const batchedHttpLink = new (_batchHttp().BatchHttpLink)({
|
|
167
|
+
const batchHttpLink = new (_batchHttp().BatchHttpLink)({
|
|
179
168
|
uri: serverUrl,
|
|
180
169
|
credentials: 'include',
|
|
181
170
|
batchInterval: this.config.batchInterval,
|
|
@@ -183,16 +172,10 @@ class GraphqlUI {
|
|
|
183
172
|
headers,
|
|
184
173
|
fetch: _crossFetch().default
|
|
185
174
|
});
|
|
186
|
-
const
|
|
187
|
-
uri: serverUrl,
|
|
188
|
-
credentials: 'include',
|
|
189
|
-
headers,
|
|
190
|
-
fetch: _crossFetch().default
|
|
191
|
-
});
|
|
192
|
-
const httpLink = _client().ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
175
|
+
const transport = _client().ApolloLink.split(this.shouldBatch, batchHttpLink, httpLink);
|
|
193
176
|
return new (_client().ApolloClient)({
|
|
194
177
|
ssrMode: true,
|
|
195
|
-
link: _client().ApolloLink.from([(0, _error().onError)(_logging().logError),
|
|
178
|
+
link: _client().ApolloLink.from([(0, _error().onError)(_logging().logError), transport]),
|
|
196
179
|
cache: this.createCache()
|
|
197
180
|
});
|
|
198
181
|
}
|
|
@@ -208,6 +191,19 @@ class GraphqlUI {
|
|
|
208
191
|
// same env). Disabling normalization stores aspects inline per component.
|
|
209
192
|
Aspect: {
|
|
210
193
|
keyFields: false
|
|
194
|
+
},
|
|
195
|
+
Query: {
|
|
196
|
+
fields: {
|
|
197
|
+
// The schema federates `ComponentHost` extensions across aspects (component-compare's
|
|
198
|
+
// `apiDiff`, scope's `get`/`getMany`, etc.). Different queries select different field
|
|
199
|
+
// subsets of the same ComponentHost — without a merge policy Apollo replaces the
|
|
200
|
+
// whole entry and warns about data loss. Field-level merge keeps each query's data
|
|
201
|
+
// additive on the shared ComponentHost cache entry.
|
|
202
|
+
getHost: {
|
|
203
|
+
keyArgs: ['id'],
|
|
204
|
+
merge: (existing, incoming) => _objectSpread(_objectSpread({}, existing), incoming)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
211
207
|
}
|
|
212
208
|
}
|
|
213
209
|
});
|
|
@@ -217,47 +213,25 @@ class GraphqlUI {
|
|
|
217
213
|
createLink(uri, {
|
|
218
214
|
subscriptionUri
|
|
219
215
|
} = {}) {
|
|
220
|
-
if (this.config.enableBatching) {
|
|
221
|
-
return this.createLinkBatched(uri, {
|
|
222
|
-
subscriptionUri
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
216
|
const httpLink = new (_client().HttpLink)({
|
|
226
217
|
credentials: 'include',
|
|
227
218
|
uri
|
|
228
219
|
});
|
|
229
|
-
const
|
|
230
|
-
uri: subscriptionUri,
|
|
231
|
-
options: {
|
|
232
|
-
reconnect: true
|
|
233
|
-
}
|
|
234
|
-
}) : undefined;
|
|
235
|
-
const hybridLink = subsLink ? (0, _createLink().createSplitLink)(httpLink, subsLink) : httpLink;
|
|
236
|
-
const errorLogger = (0, _error().onError)(_logging().logError);
|
|
237
|
-
return _client().ApolloLink.from([errorLogger, hybridLink]);
|
|
238
|
-
}
|
|
239
|
-
createLinkBatched(uri, {
|
|
240
|
-
subscriptionUri
|
|
241
|
-
} = {}) {
|
|
242
|
-
const batchedHttpLink = new (_batchHttp().BatchHttpLink)({
|
|
220
|
+
const batchHttpLink = new (_batchHttp().BatchHttpLink)({
|
|
243
221
|
uri,
|
|
244
222
|
credentials: 'include',
|
|
245
223
|
batchInterval: this.config.batchInterval,
|
|
246
224
|
batchMax: this.config.batchMax
|
|
247
225
|
});
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
credentials: 'include'
|
|
251
|
-
});
|
|
252
|
-
const httpLink = _client().ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
253
|
-
const wsLink = subscriptionUri ? new (_ws().WebSocketLink)({
|
|
226
|
+
const httpOrBatchLink = _client().ApolloLink.split(this.shouldBatch, batchHttpLink, httpLink);
|
|
227
|
+
const subsLink = subscriptionUri ? new (_ws().WebSocketLink)({
|
|
254
228
|
uri: subscriptionUri,
|
|
255
229
|
options: {
|
|
256
230
|
reconnect: true
|
|
257
231
|
}
|
|
258
232
|
}) : undefined;
|
|
259
|
-
const
|
|
260
|
-
return _client().ApolloLink.from([(0, _error().onError)(_logging().logError),
|
|
233
|
+
const hybridLink = subsLink ? (0, _createLink().createSplitLink)(httpOrBatchLink, subsLink) : httpOrBatchLink;
|
|
234
|
+
return _client().ApolloLink.from([(0, _error().onError)(_logging().logError), hybridLink]);
|
|
261
235
|
}
|
|
262
236
|
static async provider(_, config) {
|
|
263
237
|
return new GraphqlUI(config);
|
|
@@ -1 +1 @@
|
|
|
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","typePolicies","Aspect","keyFields","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 typePolicies: {\n // The Aspect type has an `id` field (the aspect ID, e.g. \"teambit.envs/envs\").\n // Without this, Apollo normalizes all Aspect objects by __typename:id, causing\n // every component to share a single cache entry per aspect ID. This means the\n // last-written aspect data overwrites all others (e.g. all components show the\n // same env). Disabling normalization stores aspects inline per component.\n Aspect: { keyFields: false },\n },\n });\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;EA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Q,EAAE;AACZ,CAAC;AAOHyB,wBAAa,CAACC,UAAU,CAACxE,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","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","GraphqlUI","constructor","config","op","enableBatching","def","getMainDefinition","query","kind","operation","getContext","batch","client","children","createElement","GraphQLProvider","GraphqlRenderPlugins","createClient","uri","state","subscriptionUri","host","defaultOptions","fetchPolicy","watchQuery","mutate","undefined","ApolloClient","link","createLink","cache","createCache","createSsrClient","serverUrl","headers","httpLink","HttpLink","credentials","fetch","crossFetch","batchHttpLink","BatchHttpLink","batchInterval","batchMax","transport","ApolloLink","split","shouldBatch","ssrMode","from","onError","logError","InMemoryCache","typePolicies","Aspect","keyFields","Query","fields","getHost","keyArgs","merge","existing","incoming","restore","httpOrBatchLink","subsLink","WebSocketLink","options","reconnect","hybridLink","createSplitLink","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 } 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 /**\n * master switch for request batching, off by default (a workspace opts in). When enabled, batching is\n * still *per-operation opt-in*: only Apollo operations that set `context: { batch: true }` are coalesced\n * via BatchHttpLink; everything else goes through a plain HttpLink. When disabled (the default) NO\n * operation batches regardless of its context — a global opt-out for the whole workspace. Mutations\n * never batch. tune the batching window/cap via the fields below.\n */\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 const httpLink = new HttpLink({\n uri: serverUrl,\n credentials: 'include',\n headers,\n fetch: crossFetch,\n });\n const batchHttpLink = 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 const transport = ApolloLink.split(this.shouldBatch, batchHttpLink, httpLink);\n\n return new ApolloClient({\n ssrMode: true,\n link: ApolloLink.from([onError(logError), transport]),\n cache: this.createCache(),\n });\n }\n\n private createCache({ state }: { state?: NormalizedCacheObject } = {}) {\n const cache = new InMemoryCache({\n typePolicies: {\n // The Aspect type has an `id` field (the aspect ID, e.g. \"teambit.envs/envs\").\n // Without this, Apollo normalizes all Aspect objects by __typename:id, causing\n // every component to share a single cache entry per aspect ID. This means the\n // last-written aspect data overwrites all others (e.g. all components show the\n // same env). Disabling normalization stores aspects inline per component.\n Aspect: { keyFields: false },\n Query: {\n fields: {\n // The schema federates `ComponentHost` extensions across aspects (component-compare's\n // `apiDiff`, scope's `get`/`getMany`, etc.). Different queries select different field\n // subsets of the same ComponentHost — without a merge policy Apollo replaces the\n // whole entry and warns about data loss. Field-level merge keeps each query's data\n // additive on the shared ComponentHost cache entry.\n getHost: {\n keyArgs: ['id'],\n merge: (existing, incoming) => ({ ...existing, ...incoming }),\n },\n },\n },\n },\n });\n\n if (state) cache.restore(state);\n\n return cache;\n }\n\n // batch only when the workspace enabled batching (`enableBatching`, default off) AND the operation\n // opted in via `context: { batch: true }`. mutations never batch.\n private readonly shouldBatch = (op: Operation) => {\n if (!this.config.enableBatching) return false;\n const def = getMainDefinition(op.query) as OperationDefinitionNode;\n if (def.kind === 'OperationDefinition' && def.operation === 'mutation') return false;\n return op.getContext().batch === true;\n };\n\n private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {\n const httpLink = new HttpLink({ credentials: 'include', uri });\n const batchHttpLink = new BatchHttpLink({\n uri,\n credentials: 'include',\n batchInterval: this.config.batchInterval,\n batchMax: this.config.batchMax,\n });\n const httpOrBatchLink = ApolloLink.split(this.shouldBatch, batchHttpLink, httpLink);\n\n const subsLink = subscriptionUri\n ? new WebSocketLink({ uri: subscriptionUri, options: { reconnect: true } })\n : undefined;\n const hybridLink = subsLink ? createSplitLink(httpOrBatchLink, subsLink) : httpOrBatchLink;\n\n return ApolloLink.from([onError(logError), hybridLink]);\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,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,QAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,IAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,GAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,OAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,WAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,UAAA,YAAAA,CAAA;IA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nB,oBAAU,CAACI,IAAI,CAAC,CAAC,IAAAC,gBAAO,EAACC,mBAAQ,CAAC,EAAEkB,UAAU,CAAC,CAAC;EACzD;EAkBA,aAAaE,QAAQA,CAACC,CAAC,EAAEtE,MAAqB,EAAE;IAC9C,OAAO,IAAIF,SAAS,CAACE,MAAM,CAAC;EAC9B;AACF;AAACuE,OAAA,CAAAzE,SAAA,GAAAA,SAAA;AAAAhB,eAAA,CA/HYgB,SAAS,aAkHH0E,eAAS;AAAA1F,eAAA,CAlHfgB,SAAS,kBAmHE,EAAE;AAAAhB,eAAA,CAnHbgB,SAAS,WAoHL,EAAE;AAAAhB,eAAA,CApHNgB,SAAS,mBAsHkB;EACpCI,cAAc,EAAE,KAAK;EACrBsC,aAAa,EAAE,EAAE;EACjBC,QAAQ,EAAE;AACZ,CAAC;AAOHgC,wBAAa,CAACC,UAAU,CAAC5E,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.1081/dist/graphql.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_graphql@1.0.1081/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
|
@@ -2,7 +2,7 @@ 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
|
-
import { InMemoryCache, ApolloClient, ApolloLink, HttpLink
|
|
5
|
+
import { InMemoryCache, ApolloClient, ApolloLink, HttpLink } from '@apollo/client';
|
|
6
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';
|
|
@@ -33,6 +33,13 @@ type ClientOptions = {
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export type GraphQLConfig = {
|
|
36
|
+
/**
|
|
37
|
+
* master switch for request batching, off by default (a workspace opts in). When enabled, batching is
|
|
38
|
+
* still *per-operation opt-in*: only Apollo operations that set `context: { batch: true }` are coalesced
|
|
39
|
+
* via BatchHttpLink; everything else goes through a plain HttpLink. When disabled (the default) NO
|
|
40
|
+
* operation batches regardless of its context — a global opt-out for the whole workspace. Mutations
|
|
41
|
+
* never batch. tune the batching window/cap via the fields below.
|
|
42
|
+
*/
|
|
36
43
|
enableBatching?: boolean;
|
|
37
44
|
batchInterval?: number;
|
|
38
45
|
batchMax?: number;
|
|
@@ -66,50 +73,25 @@ export class GraphqlUI {
|
|
|
66
73
|
}
|
|
67
74
|
|
|
68
75
|
createSsrClient({ serverUrl, headers }: { serverUrl: string; headers: any }) {
|
|
69
|
-
|
|
70
|
-
return this.createSsrClientBatched({ serverUrl, headers });
|
|
71
|
-
}
|
|
72
|
-
const link = ApolloLink.from([
|
|
73
|
-
onError(logError),
|
|
74
|
-
createHttpLink({
|
|
75
|
-
credentials: 'include',
|
|
76
|
-
uri: serverUrl,
|
|
77
|
-
headers,
|
|
78
|
-
fetch: crossFetch,
|
|
79
|
-
}),
|
|
80
|
-
]);
|
|
81
|
-
|
|
82
|
-
const client = new ApolloClient({
|
|
83
|
-
ssrMode: true,
|
|
84
|
-
link,
|
|
85
|
-
cache: this.createCache(),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
return client;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private createSsrClientBatched({ serverUrl, headers }: { serverUrl: string; headers: any }) {
|
|
92
|
-
const batchedHttpLink = new BatchHttpLink({
|
|
76
|
+
const httpLink = new HttpLink({
|
|
93
77
|
uri: serverUrl,
|
|
94
78
|
credentials: 'include',
|
|
95
|
-
batchInterval: this.config.batchInterval,
|
|
96
|
-
batchMax: this.config.batchMax,
|
|
97
79
|
headers,
|
|
98
80
|
fetch: crossFetch,
|
|
99
81
|
});
|
|
100
|
-
|
|
101
|
-
const unbatchedHttpLink = new HttpLink({
|
|
82
|
+
const batchHttpLink = new BatchHttpLink({
|
|
102
83
|
uri: serverUrl,
|
|
103
84
|
credentials: 'include',
|
|
85
|
+
batchInterval: this.config.batchInterval,
|
|
86
|
+
batchMax: this.config.batchMax,
|
|
104
87
|
headers,
|
|
105
88
|
fetch: crossFetch,
|
|
106
89
|
});
|
|
107
|
-
|
|
108
|
-
const httpLink = ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
90
|
+
const transport = ApolloLink.split(this.shouldBatch, batchHttpLink, httpLink);
|
|
109
91
|
|
|
110
92
|
return new ApolloClient({
|
|
111
93
|
ssrMode: true,
|
|
112
|
-
link: ApolloLink.from([onError(logError),
|
|
94
|
+
link: ApolloLink.from([onError(logError), transport]),
|
|
113
95
|
cache: this.createCache(),
|
|
114
96
|
});
|
|
115
97
|
}
|
|
@@ -123,6 +105,19 @@ export class GraphqlUI {
|
|
|
123
105
|
// last-written aspect data overwrites all others (e.g. all components show the
|
|
124
106
|
// same env). Disabling normalization stores aspects inline per component.
|
|
125
107
|
Aspect: { keyFields: false },
|
|
108
|
+
Query: {
|
|
109
|
+
fields: {
|
|
110
|
+
// The schema federates `ComponentHost` extensions across aspects (component-compare's
|
|
111
|
+
// `apiDiff`, scope's `get`/`getMany`, etc.). Different queries select different field
|
|
112
|
+
// subsets of the same ComponentHost — without a merge policy Apollo replaces the
|
|
113
|
+
// whole entry and warns about data loss. Field-level merge keeps each query's data
|
|
114
|
+
// additive on the shared ComponentHost cache entry.
|
|
115
|
+
getHost: {
|
|
116
|
+
keyArgs: ['id'],
|
|
117
|
+
merge: (existing, incoming) => ({ ...existing, ...incoming }),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
126
121
|
},
|
|
127
122
|
});
|
|
128
123
|
|
|
@@ -131,51 +126,31 @@ export class GraphqlUI {
|
|
|
131
126
|
return cache;
|
|
132
127
|
}
|
|
133
128
|
|
|
134
|
-
|
|
129
|
+
// batch only when the workspace enabled batching (`enableBatching`, default off) AND the operation
|
|
130
|
+
// opted in via `context: { batch: true }`. mutations never batch.
|
|
131
|
+
private readonly shouldBatch = (op: Operation) => {
|
|
132
|
+
if (!this.config.enableBatching) return false;
|
|
135
133
|
const def = getMainDefinition(op.query) as OperationDefinitionNode;
|
|
136
|
-
|
|
134
|
+
if (def.kind === 'OperationDefinition' && def.operation === 'mutation') return false;
|
|
135
|
+
return op.getContext().batch === true;
|
|
137
136
|
};
|
|
138
137
|
|
|
139
138
|
private createLink(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {
|
|
140
|
-
if (this.config.enableBatching) {
|
|
141
|
-
return this.createLinkBatched(uri, { subscriptionUri });
|
|
142
|
-
}
|
|
143
139
|
const httpLink = new HttpLink({ credentials: 'include', uri });
|
|
144
|
-
const
|
|
145
|
-
? new WebSocketLink({
|
|
146
|
-
uri: subscriptionUri,
|
|
147
|
-
options: { reconnect: true },
|
|
148
|
-
})
|
|
149
|
-
: undefined;
|
|
150
|
-
|
|
151
|
-
const hybridLink = subsLink ? createSplitLink(httpLink, subsLink) : httpLink;
|
|
152
|
-
const errorLogger = onError(logError);
|
|
153
|
-
|
|
154
|
-
return ApolloLink.from([errorLogger, hybridLink]);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private createLinkBatched(uri: string, { subscriptionUri }: { subscriptionUri?: string } = {}) {
|
|
158
|
-
const batchedHttpLink = new BatchHttpLink({
|
|
140
|
+
const batchHttpLink = new BatchHttpLink({
|
|
159
141
|
uri,
|
|
160
142
|
credentials: 'include',
|
|
161
143
|
batchInterval: this.config.batchInterval,
|
|
162
144
|
batchMax: this.config.batchMax,
|
|
163
145
|
});
|
|
146
|
+
const httpOrBatchLink = ApolloLink.split(this.shouldBatch, batchHttpLink, httpLink);
|
|
164
147
|
|
|
165
|
-
const
|
|
166
|
-
uri,
|
|
167
|
-
credentials: 'include',
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
const httpLink = ApolloLink.split(this.isMutation, unbatchedHttpLink, batchedHttpLink);
|
|
171
|
-
|
|
172
|
-
const wsLink = subscriptionUri
|
|
148
|
+
const subsLink = subscriptionUri
|
|
173
149
|
? new WebSocketLink({ uri: subscriptionUri, options: { reconnect: true } })
|
|
174
150
|
: undefined;
|
|
151
|
+
const hybridLink = subsLink ? createSplitLink(httpOrBatchLink, subsLink) : httpOrBatchLink;
|
|
175
152
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return ApolloLink.from([onError(logError), transport]);
|
|
153
|
+
return ApolloLink.from([onError(logError), hybridLink]);
|
|
179
154
|
}
|
|
180
155
|
|
|
181
156
|
getProvider = ({ client, children }: { client: GraphQLClient<any>; children: ReactNode }) => {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/graphql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1081",
|
|
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.1081"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@graphql-tools/schema": "^10.0.0",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"utf-8-validate": "5.0.5",
|
|
32
32
|
"bufferutil": "4.0.3",
|
|
33
33
|
"@teambit/harmony": "0.4.12",
|
|
34
|
-
"@teambit/cli": "0.0.1357",
|
|
35
|
-
"@teambit/logger": "0.0.1450",
|
|
36
34
|
"@teambit/toolbox.network.get-port": "1.0.25",
|
|
37
35
|
"@teambit/ui-foundation.ui.is-browser": "0.0.500",
|
|
38
|
-
"@teambit/
|
|
36
|
+
"@teambit/cli": "0.0.1358",
|
|
37
|
+
"@teambit/logger": "0.0.1451",
|
|
38
|
+
"@teambit/ui": "1.0.1081"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/cors": "2.8.10",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/lodash": "4.14.165",
|
|
45
45
|
"@types/node-fetch": "2.5.12",
|
|
46
46
|
"@types/mocha": "9.1.0",
|
|
47
|
-
"@teambit/harmony.envs.core-aspect-env": "2.0.
|
|
47
|
+
"@teambit/harmony.envs.core-aspect-env": "2.0.3"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@apollo/client": "^3.12.0",
|