@steedos/service-object-graphql 2.4.10 → 2.4.11-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -4
  2. package/package.service.js +35 -77
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/service-object-graphql",
3
- "version": "2.4.10",
3
+ "version": "2.4.11-beta.2",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -15,10 +15,11 @@
15
15
  "description": "steedos package",
16
16
  "repository": {},
17
17
  "license": "MIT",
18
- "gitHead": "1ee65d966cd75599e20a8aa520327a05fd326ca2",
18
+ "gitHead": "b87601438ab4f5c0822d37755a4f0ccb2fe204cb",
19
19
  "dependencies": {
20
- "@steedos/i18n": "2.4.10",
21
- "@steedos/objectql": "2.4.10",
20
+ "@steedos/i18n": "2.4.11-beta.2",
21
+ "@steedos/objectql": "2.4.11-beta.2",
22
+ "@steedos/service-object-mixin": "2.4.11-beta.2",
22
23
  "graphql": "^15.8.0",
23
24
  "graphql-parse-resolve-info": "^4.12.3",
24
25
  "moleculer": "^0.14.25",
@@ -2,7 +2,7 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2023-03-23 15:12:14
4
4
  * @LastEditors: sunhaolin@hotoa.com
5
- * @LastEditTime: 2023-03-29 14:59:59
5
+ * @LastEditTime: 2023-04-07 11:53:24
6
6
  * @Description:
7
7
  */
8
8
 
@@ -16,13 +16,15 @@ const {
16
16
  } = require('./lib');
17
17
  const open = require('open');
18
18
 
19
+ const serviceObjectMixin = require('@steedos/service-object-mixin');
20
+
19
21
  /**
20
22
  * @typedef {import('moleculer').Context} Context Moleculer's Context
21
23
  */
22
24
  module.exports = {
23
25
  name: 'graphql',
24
26
  namespace: "steedos",
25
- mixins: [],
27
+ mixins: [serviceObjectMixin],
26
28
 
27
29
  globalTypeDefs: [], // service-api 里generateGraphQLSchema使用
28
30
 
@@ -234,25 +236,25 @@ module.exports = {
234
236
  }
235
237
  },
236
238
 
237
- /**
238
- * @api {get} /service/api/graphql/generateGraphqlSchemaInfo 生成graphql schema
239
- * @apiName generateGraphqlSchemaInfo
240
- * @apiGroup service-object-graphql
241
- * @apiSuccess {Object}
242
- */
243
- generateGraphqlSchemaInfo: {
244
- rest: {
245
- method: 'GET',
246
- path: '/generateGraphqlSchemaInfo'
247
- },
248
- params: {
249
- },
250
- async handler(ctx) {
251
- this.broker.logger.info('[service][graphql]===>', 'generateGraphqlSchemaInfo', ctx.params.name)
252
- const settingsGraphql = await this.generateObjGraphqlMap(this.name)
253
- return settingsGraphql
254
- }
255
- },
239
+ // /**
240
+ // * @api {get} /service/api/graphql/generateGraphqlSchemaInfo 生成graphql schema
241
+ // * @apiName generateGraphqlSchemaInfo
242
+ // * @apiGroup service-object-graphql
243
+ // * @apiSuccess {Object}
244
+ // */
245
+ // generateGraphqlSchemaInfo: {
246
+ // rest: {
247
+ // method: 'GET',
248
+ // path: '/generateGraphqlSchemaInfo'
249
+ // },
250
+ // params: {
251
+ // },
252
+ // async handler(ctx) {
253
+ // this.broker.logger.info('[service][graphql]===>', 'generateGraphqlSchemaInfo', ctx.params.name)
254
+ // const settingsGraphql = await this.generateObjGraphqlMap(this.name)
255
+ // return settingsGraphql
256
+ // }
257
+ // },
256
258
 
257
259
  },
258
260
 
@@ -333,88 +335,44 @@ module.exports = {
333
335
 
334
336
  find: {
335
337
  async handler(objectName, query, userSession) {
336
- const obj = getObject(objectName)
338
+ const obj = this.getObject(objectName)
337
339
  if (objectName == 'users') {
338
340
  return await obj.find(query)
339
341
  }
340
- return await this.broker.call("objectql.find", {
341
- objectName: objectName,
342
- query: query
343
- }, {
344
- meta: {
345
- user: userSession
346
- }
347
- })
342
+ return await obj.find(query, userSession)
348
343
  }
349
344
  },
350
345
  count: {
351
346
  async handler(objectName, query, userSession) {
352
- const obj = getObject(objectName)
353
- return await this.broker.call("objectql.count", {
354
- objectName: objectName,
355
- query: query,
356
- }, {
357
- meta: {
358
- user: userSession
359
- }
360
- })
347
+ const obj = this.getObject(objectName)
348
+ return await obj.count(query, userSession)
361
349
  }
362
350
  },
363
351
  findOne: {
364
352
  async handler(objectName, id, query, userSession) {
365
- const obj = getObject(objectName)
353
+ const obj = this.getObject(objectName)
366
354
  if (objectName == 'users') {
367
355
  return await obj.findOne(id, query)
368
356
  }
369
- return await this.broker.call("objectql.findOne", {
370
- objectName: objectName,
371
- id: id,
372
- query: query,
373
- }, {
374
- meta: {
375
- user: userSession
376
- }
377
- })
357
+ return await obj.findOne(id, query, userSession)
378
358
  }
379
359
  },
380
360
  insert: {
381
361
  async handler(objectName, doc, userSession) {
382
- const obj = getObject(objectName)
383
- return await this.broker.call("objectql.insert", {
384
- objectName: objectName,
385
- doc: doc,
386
- }, {
387
- meta: {
388
- user: userSession
389
- }
390
- })
362
+ const obj = this.getObject(objectName)
363
+ return await obj.insert(doc, userSession)
391
364
  }
392
365
  },
393
366
  update: {
394
367
  async handler(objectName, id, doc, userSession) {
395
- const obj = getObject(objectName)
396
- return await this.broker.call("objectql.update", {
397
- objectName: objectName,
398
- id: id,
399
- doc: doc,
400
- }, {
401
- meta: {
402
- user: userSession
403
- }
404
- })
368
+ const obj = this.getObject(objectName)
369
+ return await obj.update(id, doc, userSession)
405
370
  }
406
371
  },
407
372
  delete: {
408
373
  async handler(objectName, id, userSession) {
409
- const obj = getObject(objectName)
410
- return await this.broker.call("objectql.delete", {
411
- objectName: objectName,
412
- id: id,
413
- }, {
414
- meta: {
415
- user: userSession
416
- }
417
- })
374
+ const obj = this.getObject(objectName)
375
+ return await obj.delete(id, userSession)
418
376
  }
419
377
  },
420
378