@steedos/service-api 2.5.13-beta.8 → 2.5.13
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/index.js +17 -11
- package/package.json +6 -6
package/index.js
CHANGED
|
@@ -86,7 +86,7 @@ const mixinOptions = {
|
|
|
86
86
|
introspection: enablePlayground
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
const ObjectDataLoaderMapKeys = {};
|
|
90
90
|
/**
|
|
91
91
|
* @typedef {import('moleculer').Context} Context Moleculer's Context
|
|
92
92
|
* @typedef {import('http').IncomingMessage} IncomingRequest Incoming HTTP Request
|
|
@@ -324,9 +324,14 @@ module.exports = {
|
|
|
324
324
|
* @param {Object.<string, any>} args - Arguments passed to GraphQL child resolver
|
|
325
325
|
* @returns {string} Key to the dataloader instance
|
|
326
326
|
*/
|
|
327
|
-
getObjectDataLoaderMapKey(objectName) {
|
|
327
|
+
getObjectDataLoaderMapKey(objectName, referenceToField = '_id') {
|
|
328
328
|
if (objectName) {
|
|
329
|
-
|
|
329
|
+
const key = `object:${objectName}.${referenceToField}`;
|
|
330
|
+
if(!ObjectDataLoaderMapKeys[objectName]){
|
|
331
|
+
ObjectDataLoaderMapKeys[objectName] = [] ;
|
|
332
|
+
}
|
|
333
|
+
ObjectDataLoaderMapKeys[objectName].push(key);
|
|
334
|
+
return key;
|
|
330
335
|
}
|
|
331
336
|
// 如果没有objectName,则抛出错误信息
|
|
332
337
|
throw new Error("objectName is required");
|
|
@@ -338,6 +343,7 @@ module.exports = {
|
|
|
338
343
|
const {root, args, context, resolveInfo} = graphqlCtx;
|
|
339
344
|
const dataLoaderMapKey = this.getObjectDataLoaderMapKey(
|
|
340
345
|
staticParams.__objectName || staticParams.objectName
|
|
346
|
+
, staticParams.referenceToField || '_id'
|
|
341
347
|
);
|
|
342
348
|
const objectDataLoaders = this.objectDataLoaders;
|
|
343
349
|
// if a dataLoader batching parameter is specified, then all root params can be data loaded;
|
|
@@ -937,19 +943,19 @@ module.exports = {
|
|
|
937
943
|
'@objectRecordEvent.*.*': function(ctx){
|
|
938
944
|
const { objectApiName, isUpdate, isDelete, id, doc } = ctx.params;
|
|
939
945
|
if(objectApiName && (isUpdate || isDelete)){
|
|
940
|
-
const
|
|
941
|
-
objectApiName
|
|
942
|
-
);
|
|
946
|
+
const keys = ObjectDataLoaderMapKeys[objectApiName] || [];
|
|
943
947
|
let dataLoaderKeys = [id];
|
|
944
948
|
if(objectApiName === 'space_users'){
|
|
945
949
|
dataLoaderKeys.push(doc.user)
|
|
946
950
|
}
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
+
_.each(keys, (key)=>{
|
|
952
|
+
const loader = this.objectDataLoaders.get(key);
|
|
953
|
+
if(loader){
|
|
954
|
+
for(const dataLoaderKey of dataLoaderKeys){
|
|
955
|
+
loader.clear(dataLoaderKey);
|
|
956
|
+
}
|
|
951
957
|
}
|
|
952
|
-
}
|
|
958
|
+
})
|
|
953
959
|
}
|
|
954
960
|
},
|
|
955
961
|
'service-ui.started': function(){
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-api",
|
|
3
|
-
"version": "2.5.13
|
|
3
|
+
"version": "2.5.13",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@steedos/auth": "2.5.13
|
|
8
|
-
"@steedos/router": "2.5.13
|
|
9
|
-
"@steedos/service-object-graphql": "2.5.13
|
|
10
|
-
"@steedos/service-ui": "2.5.13
|
|
7
|
+
"@steedos/auth": "2.5.13",
|
|
8
|
+
"@steedos/router": "2.5.13",
|
|
9
|
+
"@steedos/service-object-graphql": "2.5.13",
|
|
10
|
+
"@steedos/service-ui": "2.5.13",
|
|
11
11
|
"graphql": "^15.8.0",
|
|
12
12
|
"graphql-iso-date": "^3.6.1",
|
|
13
13
|
"graphql-type-json": "^0.3.2",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "70670f8b8ea0aad61e73a3258b5c8aaf6139c682",
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/graphql-iso-date": "^3.4.0",
|
|
28
28
|
"@types/react-dev-utils": "^9.0.11"
|