@strapi/plugin-graphql 5.18.0 → 5.19.0
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/admin/package.json.js +10 -8
- package/dist/admin/package.json.js.map +1 -1
- package/dist/admin/package.json.mjs +10 -8
- package/dist/admin/package.json.mjs.map +1 -1
- package/dist/server/services/builders/resolvers/association.js +14 -1
- package/dist/server/services/builders/resolvers/association.js.map +1 -1
- package/dist/server/services/builders/resolvers/association.mjs +14 -1
- package/dist/server/services/builders/resolvers/association.mjs.map +1 -1
- package/dist/server/src/services/builders/resolvers/association.d.ts.map +1 -1
- package/package.json +10 -8
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var name = "@strapi/plugin-graphql";
|
|
6
|
-
var version = "5.
|
|
6
|
+
var version = "5.19.0";
|
|
7
7
|
var description = "Adds GraphQL endpoint with default API methods.";
|
|
8
8
|
var repository = {
|
|
9
9
|
type: "git",
|
|
@@ -52,6 +52,8 @@ var scripts = {
|
|
|
52
52
|
"build:types:admin": "run -T tsc -p admin/tsconfig.build.json --emitDeclarationOnly",
|
|
53
53
|
clean: "run -T rimraf ./dist",
|
|
54
54
|
lint: "run -T eslint .",
|
|
55
|
+
"test:unit": "run -T jest --passWithNoTests",
|
|
56
|
+
"test:unit:watch": "run -T jest --watch",
|
|
55
57
|
watch: "run -T rollup -c -w"
|
|
56
58
|
};
|
|
57
59
|
var dependencies = {
|
|
@@ -60,9 +62,9 @@ var dependencies = {
|
|
|
60
62
|
"@graphql-tools/schema": "10.0.3",
|
|
61
63
|
"@graphql-tools/utils": "^10.1.3",
|
|
62
64
|
"@koa/cors": "5.0.0",
|
|
63
|
-
"@strapi/design-system": "2.0.0-rc.
|
|
64
|
-
"@strapi/icons": "2.0.0-rc.
|
|
65
|
-
"@strapi/utils": "5.
|
|
65
|
+
"@strapi/design-system": "2.0.0-rc.29",
|
|
66
|
+
"@strapi/icons": "2.0.0-rc.29",
|
|
67
|
+
"@strapi/utils": "5.19.0",
|
|
66
68
|
graphql: "^16.8.1",
|
|
67
69
|
"graphql-depth-limit": "^1.1.0",
|
|
68
70
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -74,19 +76,19 @@ var dependencies = {
|
|
|
74
76
|
pluralize: "8.0.0"
|
|
75
77
|
};
|
|
76
78
|
var devDependencies = {
|
|
77
|
-
"@strapi/strapi": "5.
|
|
78
|
-
"@strapi/types": "5.
|
|
79
|
+
"@strapi/strapi": "5.19.0",
|
|
80
|
+
"@strapi/types": "5.19.0",
|
|
79
81
|
"@types/graphql-depth-limit": "1.1.5",
|
|
80
82
|
"@types/koa-bodyparser": "4.3.12",
|
|
81
83
|
"@types/koa__cors": "5.0.0",
|
|
82
84
|
"cross-env": "^7.0.3",
|
|
83
|
-
"eslint-config-custom": "5.
|
|
85
|
+
"eslint-config-custom": "5.19.0",
|
|
84
86
|
koa: "2.16.1",
|
|
85
87
|
react: "18.3.1",
|
|
86
88
|
"react-dom": "18.3.1",
|
|
87
89
|
"react-router-dom": "6.22.3",
|
|
88
90
|
"styled-components": "6.1.8",
|
|
89
|
-
tsconfig: "5.
|
|
91
|
+
tsconfig: "5.19.0",
|
|
90
92
|
typescript: "5.4.4"
|
|
91
93
|
};
|
|
92
94
|
var peerDependencies = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var name = "@strapi/plugin-graphql";
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.19.0";
|
|
3
3
|
var description = "Adds GraphQL endpoint with default API methods.";
|
|
4
4
|
var repository = {
|
|
5
5
|
type: "git",
|
|
@@ -48,6 +48,8 @@ var scripts = {
|
|
|
48
48
|
"build:types:admin": "run -T tsc -p admin/tsconfig.build.json --emitDeclarationOnly",
|
|
49
49
|
clean: "run -T rimraf ./dist",
|
|
50
50
|
lint: "run -T eslint .",
|
|
51
|
+
"test:unit": "run -T jest --passWithNoTests",
|
|
52
|
+
"test:unit:watch": "run -T jest --watch",
|
|
51
53
|
watch: "run -T rollup -c -w"
|
|
52
54
|
};
|
|
53
55
|
var dependencies = {
|
|
@@ -56,9 +58,9 @@ var dependencies = {
|
|
|
56
58
|
"@graphql-tools/schema": "10.0.3",
|
|
57
59
|
"@graphql-tools/utils": "^10.1.3",
|
|
58
60
|
"@koa/cors": "5.0.0",
|
|
59
|
-
"@strapi/design-system": "2.0.0-rc.
|
|
60
|
-
"@strapi/icons": "2.0.0-rc.
|
|
61
|
-
"@strapi/utils": "5.
|
|
61
|
+
"@strapi/design-system": "2.0.0-rc.29",
|
|
62
|
+
"@strapi/icons": "2.0.0-rc.29",
|
|
63
|
+
"@strapi/utils": "5.19.0",
|
|
62
64
|
graphql: "^16.8.1",
|
|
63
65
|
"graphql-depth-limit": "^1.1.0",
|
|
64
66
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -70,19 +72,19 @@ var dependencies = {
|
|
|
70
72
|
pluralize: "8.0.0"
|
|
71
73
|
};
|
|
72
74
|
var devDependencies = {
|
|
73
|
-
"@strapi/strapi": "5.
|
|
74
|
-
"@strapi/types": "5.
|
|
75
|
+
"@strapi/strapi": "5.19.0",
|
|
76
|
+
"@strapi/types": "5.19.0",
|
|
75
77
|
"@types/graphql-depth-limit": "1.1.5",
|
|
76
78
|
"@types/koa-bodyparser": "4.3.12",
|
|
77
79
|
"@types/koa__cors": "5.0.0",
|
|
78
80
|
"cross-env": "^7.0.3",
|
|
79
|
-
"eslint-config-custom": "5.
|
|
81
|
+
"eslint-config-custom": "5.19.0",
|
|
80
82
|
koa: "2.16.1",
|
|
81
83
|
react: "18.3.1",
|
|
82
84
|
"react-dom": "18.3.1",
|
|
83
85
|
"react-router-dom": "6.22.3",
|
|
84
86
|
"styled-components": "6.1.8",
|
|
85
|
-
tsconfig: "5.
|
|
87
|
+
tsconfig: "5.19.0",
|
|
86
88
|
typescript: "5.4.4"
|
|
87
89
|
};
|
|
88
90
|
var peerDependencies = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"package.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -43,7 +43,20 @@ var associationResolvers = (({ strapi })=>{
|
|
|
43
43
|
}
|
|
44
44
|
} : {};
|
|
45
45
|
const dbQuery = fp.merge(defaultFilters, transformedQuery);
|
|
46
|
-
|
|
46
|
+
// Sign media URLs if upload plugin is available and using private provider
|
|
47
|
+
const data = await (async ()=>{
|
|
48
|
+
const rawData = await strapi.db.query(contentTypeUID).load(parent, attributeName, dbQuery);
|
|
49
|
+
if (isMediaAttribute && strapi.plugin('upload')) {
|
|
50
|
+
const { signFileUrls } = strapi.plugin('upload').service('file');
|
|
51
|
+
if (Array.isArray(rawData)) {
|
|
52
|
+
return utils.async.map(rawData, (item)=>signFileUrls(item));
|
|
53
|
+
}
|
|
54
|
+
if (rawData) {
|
|
55
|
+
return signFileUrls(rawData);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return rawData;
|
|
59
|
+
})();
|
|
47
60
|
const info = {
|
|
48
61
|
args: sanitizedQuery,
|
|
49
62
|
resourceUID: targetUID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association.js","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n const defaultFilters = isTargetDraftAndPublishContentType\n ? {\n where: {\n publishedAt: {\n $notNull: context.rootQueryArgs?.status\n ? // Filter by the same status as the root query if the argument is present\n context.rootQueryArgs?.status === 'published'\n : // Otherwise fallback to the published version\n true,\n },\n },\n }\n : {};\n\n const dbQuery = merge(defaultFilters, transformedQuery);\n const data = await strapi.db
|
|
1
|
+
{"version":3,"file":"association.js","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n const defaultFilters = isTargetDraftAndPublishContentType\n ? {\n where: {\n publishedAt: {\n $notNull: context.rootQueryArgs?.status\n ? // Filter by the same status as the root query if the argument is present\n context.rootQueryArgs?.status === 'published'\n : // Otherwise fallback to the published version\n true,\n },\n },\n }\n : {};\n\n const dbQuery = merge(defaultFilters, transformedQuery);\n\n // Sign media URLs if upload plugin is available and using private provider\n const data = await (async () => {\n const rawData = await strapi.db\n .query(contentTypeUID)\n .load(parent, attributeName, dbQuery);\n if (isMediaAttribute && strapi.plugin('upload')) {\n const { signFileUrls } = strapi.plugin('upload').service('file');\n\n if (Array.isArray(rawData)) {\n return async.map(rawData, (item: any) => signFileUrls(item));\n }\n\n if (rawData) {\n return signFileUrls(rawData);\n }\n }\n\n return rawData;\n })();\n\n const info = {\n args: sanitizedQuery,\n resourceUID: targetUID,\n };\n\n // If this a polymorphic association, it sanitizes & returns the raw data\n // Note: The value needs to be wrapped in a fake object that represents its parent\n // so that the sanitize util can work properly.\n if (isMorphAttribute) {\n // Helpers used for the data cleanup\n const wrapData = (dataToWrap: any) => ({ [attributeName]: dataToWrap });\n const sanitizeData = (dataToSanitize: any) => {\n return strapi.contentAPI.sanitize.output(dataToSanitize, contentType, { auth });\n };\n const unwrapData = get(attributeName);\n\n // Sanitizer definition\n const sanitizeMorphAttribute = async.pipe(wrapData, sanitizeData, unwrapData);\n\n return sanitizeMorphAttribute(data);\n }\n\n // If this is a to-many relation, it returns an object that\n // matches what the entity-response-collection's resolvers expect\n if (isToMany) {\n return toEntityResponseCollection(data, info);\n }\n\n // Else, it returns an object that matches\n // what the entity-response's resolvers expect\n return toEntityResponse(data, info);\n };\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","service","getGraphQLService","plugin","isMorphRelation","isMedia","attributes","transformArgs","utils","toEntityResponse","toEntityResponseCollection","returnTypes","buildAssociationResolver","contentTypeUID","attributeName","contentType","getModel","attribute","isMediaAttribute","isMorphAttribute","targetUID","target","isToMany","multiple","relation","endsWith","targetContentType","parent","args","context","auth","state","transformedArgs","usePagination","contentAPI","validate","query","sanitizedQuery","sanitize","transformedQuery","get","transform","isTargetDraftAndPublishContentType","contentTypes","hasDraftAndPublish","defaultFilters","where","publishedAt","$notNull","rootQueryArgs","status","dbQuery","merge","data","rawData","db","load","signFileUrls","Array","isArray","async","map","item","info","resourceUID","wrapData","dataToWrap","sanitizeData","dataToSanitize","output","unwrapData","sanitizeMorphAttribute","pipe"],"mappings":";;;;;AAMA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B,2BAAe,CAAA,CAAC,EAAEC,MAAM,EAAW,GAAA;AACjC,IAAA,MAAM,EAAEC,OAASC,EAAAA,iBAAiB,EAAE,GAAGF,MAAAA,CAAOG,MAAM,CAAC,SAAA,CAAA;IAErD,MAAM,EAAEC,eAAe,EAAEC,OAAO,EAAE,GAAGH,iBAAAA,CAAkB,SAASI,UAAU;AAC1E,IAAA,MAAM,EAAEC,aAAa,EAAE,GAAGL,iBAAAA,CAAkB,YAAYM,KAAK;IAC7D,MAAM,EAAEC,gBAAgB,EAAEC,0BAA0B,EAAE,GAAGR,iBAAAA,CAAkB,UAAUS,WAAW;IAEhG,OAAO;AACLC,QAAAA,wBAAAA,CAAAA,CAAyB,EACvBC,cAAc,EACdC,aAAa,EAId,EAAA;YACC,MAAMC,WAAAA,GAAcf,MAAOgB,CAAAA,QAAQ,CAACH,cAAAA,CAAAA;AACpC,YAAA,MAAMI,SAAiBF,GAAAA,WAAAA,CAAYT,UAAU,CAACQ,aAAc,CAAA;AAE5D,YAAA,IAAI,CAACG,SAAW,EAAA;gBACd,MAAM,IAAInB,iBACR,CAAC,4CAA4C,EAAEe,cAAe,CAAA,EAAE,EAAEC,aAAAA,CAAc,CAAC,CAAA;AAErF;AAEA,YAAA,MAAMI,mBAAmBb,OAAQY,CAAAA,SAAAA,CAAAA;AACjC,YAAA,MAAME,mBAAmBf,eAAgBa,CAAAA,SAAAA,CAAAA;AAEzC,YAAA,MAAMG,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,aAAAA,CAAAA;;AAGvB,oBAAA,MAAMyD,sBAAyBX,GAAAA,WAAAA,CAAMY,IAAI,CAACP,UAAUE,YAAcG,EAAAA,UAAAA,CAAAA;AAElE,oBAAA,OAAOC,sBAAuBlB,CAAAA,IAAAA,CAAAA;AAChC;;;AAIA,gBAAA,IAAI/B,QAAU,EAAA;AACZ,oBAAA,OAAOZ,2BAA2B2C,IAAMU,EAAAA,IAAAA,CAAAA;AAC1C;;;AAIA,gBAAA,OAAOtD,iBAAiB4C,IAAMU,EAAAA,IAAAA,CAAAA;AAChC,aAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -41,7 +41,20 @@ var associationResolvers = (({ strapi })=>{
|
|
|
41
41
|
}
|
|
42
42
|
} : {};
|
|
43
43
|
const dbQuery = merge(defaultFilters, transformedQuery);
|
|
44
|
-
|
|
44
|
+
// Sign media URLs if upload plugin is available and using private provider
|
|
45
|
+
const data = await (async ()=>{
|
|
46
|
+
const rawData = await strapi.db.query(contentTypeUID).load(parent, attributeName, dbQuery);
|
|
47
|
+
if (isMediaAttribute && strapi.plugin('upload')) {
|
|
48
|
+
const { signFileUrls } = strapi.plugin('upload').service('file');
|
|
49
|
+
if (Array.isArray(rawData)) {
|
|
50
|
+
return async.map(rawData, (item)=>signFileUrls(item));
|
|
51
|
+
}
|
|
52
|
+
if (rawData) {
|
|
53
|
+
return signFileUrls(rawData);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return rawData;
|
|
57
|
+
})();
|
|
45
58
|
const info = {
|
|
46
59
|
args: sanitizedQuery,
|
|
47
60
|
resourceUID: targetUID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association.mjs","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n const defaultFilters = isTargetDraftAndPublishContentType\n ? {\n where: {\n publishedAt: {\n $notNull: context.rootQueryArgs?.status\n ? // Filter by the same status as the root query if the argument is present\n context.rootQueryArgs?.status === 'published'\n : // Otherwise fallback to the published version\n true,\n },\n },\n }\n : {};\n\n const dbQuery = merge(defaultFilters, transformedQuery);\n const data = await strapi.db
|
|
1
|
+
{"version":3,"file":"association.mjs","sources":["../../../../../server/src/services/builders/resolvers/association.ts"],"sourcesContent":["import { get, merge } from 'lodash/fp';\nimport { async, contentTypes, errors } from '@strapi/utils';\nimport type { Internal } from '@strapi/types';\n\nimport type { Context } from '../../types';\n\nconst { ApplicationError } = errors;\n\nexport default ({ strapi }: Context) => {\n const { service: getGraphQLService } = strapi.plugin('graphql');\n\n const { isMorphRelation, isMedia } = getGraphQLService('utils').attributes;\n const { transformArgs } = getGraphQLService('builders').utils;\n const { toEntityResponse, toEntityResponseCollection } = getGraphQLService('format').returnTypes;\n\n return {\n buildAssociationResolver({\n contentTypeUID,\n attributeName,\n }: {\n contentTypeUID: Internal.UID.ContentType;\n attributeName: string;\n }) {\n const contentType = strapi.getModel(contentTypeUID);\n const attribute: any = contentType.attributes[attributeName];\n\n if (!attribute) {\n throw new ApplicationError(\n `Failed to build an association resolver for ${contentTypeUID}::${attributeName}`\n );\n }\n\n const isMediaAttribute = isMedia(attribute);\n const isMorphAttribute = isMorphRelation(attribute);\n\n const targetUID = isMediaAttribute ? 'plugin::upload.file' : attribute.target;\n const isToMany = isMediaAttribute ? attribute.multiple : attribute.relation.endsWith('Many');\n\n const targetContentType = strapi.getModel(targetUID);\n\n return async (parent: any, args: any = {}, context: any = {}) => {\n const { auth } = context.state;\n\n const transformedArgs = transformArgs(args, {\n contentType: targetContentType,\n usePagination: true,\n });\n\n await strapi.contentAPI.validate.query(transformedArgs, targetContentType, {\n auth,\n });\n\n const sanitizedQuery = await strapi.contentAPI.sanitize.query(\n transformedArgs,\n targetContentType,\n {\n auth,\n }\n );\n const transformedQuery = strapi.get('query-params').transform(targetUID, sanitizedQuery);\n\n const isTargetDraftAndPublishContentType =\n contentTypes.hasDraftAndPublish(targetContentType);\n const defaultFilters = isTargetDraftAndPublishContentType\n ? {\n where: {\n publishedAt: {\n $notNull: context.rootQueryArgs?.status\n ? // Filter by the same status as the root query if the argument is present\n context.rootQueryArgs?.status === 'published'\n : // Otherwise fallback to the published version\n true,\n },\n },\n }\n : {};\n\n const dbQuery = merge(defaultFilters, transformedQuery);\n\n // Sign media URLs if upload plugin is available and using private provider\n const data = await (async () => {\n const rawData = await strapi.db\n .query(contentTypeUID)\n .load(parent, attributeName, dbQuery);\n if (isMediaAttribute && strapi.plugin('upload')) {\n const { signFileUrls } = strapi.plugin('upload').service('file');\n\n if (Array.isArray(rawData)) {\n return async.map(rawData, (item: any) => signFileUrls(item));\n }\n\n if (rawData) {\n return signFileUrls(rawData);\n }\n }\n\n return rawData;\n })();\n\n const info = {\n args: sanitizedQuery,\n resourceUID: targetUID,\n };\n\n // If this a polymorphic association, it sanitizes & returns the raw data\n // Note: The value needs to be wrapped in a fake object that represents its parent\n // so that the sanitize util can work properly.\n if (isMorphAttribute) {\n // Helpers used for the data cleanup\n const wrapData = (dataToWrap: any) => ({ [attributeName]: dataToWrap });\n const sanitizeData = (dataToSanitize: any) => {\n return strapi.contentAPI.sanitize.output(dataToSanitize, contentType, { auth });\n };\n const unwrapData = get(attributeName);\n\n // Sanitizer definition\n const sanitizeMorphAttribute = async.pipe(wrapData, sanitizeData, unwrapData);\n\n return sanitizeMorphAttribute(data);\n }\n\n // If this is a to-many relation, it returns an object that\n // matches what the entity-response-collection's resolvers expect\n if (isToMany) {\n return toEntityResponseCollection(data, info);\n }\n\n // Else, it returns an object that matches\n // what the entity-response's resolvers expect\n return toEntityResponse(data, info);\n };\n },\n };\n};\n"],"names":["ApplicationError","errors","strapi","service","getGraphQLService","plugin","isMorphRelation","isMedia","attributes","transformArgs","utils","toEntityResponse","toEntityResponseCollection","returnTypes","buildAssociationResolver","contentTypeUID","attributeName","contentType","getModel","attribute","isMediaAttribute","isMorphAttribute","targetUID","target","isToMany","multiple","relation","endsWith","targetContentType","parent","args","context","auth","state","transformedArgs","usePagination","contentAPI","validate","query","sanitizedQuery","sanitize","transformedQuery","get","transform","isTargetDraftAndPublishContentType","contentTypes","hasDraftAndPublish","defaultFilters","where","publishedAt","$notNull","rootQueryArgs","status","dbQuery","merge","data","rawData","db","load","signFileUrls","Array","isArray","async","map","item","info","resourceUID","wrapData","dataToWrap","sanitizeData","dataToSanitize","output","unwrapData","sanit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,IAAAA,CAAAA;AAC1C;;;AAIA,gBAAA,OAAOtD,iBAAiB4C,IAAMU,EAAAA,IAAAA,CAAAA;AAChC,aAAA;AACF;AACF,KAAA;AACF,CAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"association.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/builders/resolvers/association.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;qCAIf,OAAO;iEAW5B;QACD,cAAc,EAAE,SAAS,GAAG,CAAC,WAAW,CAAC;QACzC,aAAa,EAAE,MAAM,CAAC;KACvB,YAkBuB,GAAG,SAAQ,GAAG,YAAgB,GAAG;;AAhC7D,
|
|
1
|
+
{"version":3,"file":"association.d.ts","sourceRoot":"","sources":["../../../../../../server/src/services/builders/resolvers/association.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;qCAIf,OAAO;iEAW5B;QACD,cAAc,EAAE,SAAS,GAAG,CAAC,WAAW,CAAC;QACzC,aAAa,EAAE,MAAM,CAAC;KACvB,YAkBuB,GAAG,SAAQ,GAAG,YAAgB,GAAG;;AAhC7D,wBA6HE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-graphql",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.19.0",
|
|
4
4
|
"description": "Adds GraphQL endpoint with default API methods.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"build:types:admin": "run -T tsc -p admin/tsconfig.build.json --emitDeclarationOnly",
|
|
50
50
|
"clean": "run -T rimraf ./dist",
|
|
51
51
|
"lint": "run -T eslint .",
|
|
52
|
+
"test:unit": "run -T jest --passWithNoTests",
|
|
53
|
+
"test:unit:watch": "run -T jest --watch",
|
|
52
54
|
"watch": "run -T rollup -c -w"
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {
|
|
@@ -57,9 +59,9 @@
|
|
|
57
59
|
"@graphql-tools/schema": "10.0.3",
|
|
58
60
|
"@graphql-tools/utils": "^10.1.3",
|
|
59
61
|
"@koa/cors": "5.0.0",
|
|
60
|
-
"@strapi/design-system": "2.0.0-rc.
|
|
61
|
-
"@strapi/icons": "2.0.0-rc.
|
|
62
|
-
"@strapi/utils": "5.
|
|
62
|
+
"@strapi/design-system": "2.0.0-rc.29",
|
|
63
|
+
"@strapi/icons": "2.0.0-rc.29",
|
|
64
|
+
"@strapi/utils": "5.19.0",
|
|
63
65
|
"graphql": "^16.8.1",
|
|
64
66
|
"graphql-depth-limit": "^1.1.0",
|
|
65
67
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
@@ -71,19 +73,19 @@
|
|
|
71
73
|
"pluralize": "8.0.0"
|
|
72
74
|
},
|
|
73
75
|
"devDependencies": {
|
|
74
|
-
"@strapi/strapi": "5.
|
|
75
|
-
"@strapi/types": "5.
|
|
76
|
+
"@strapi/strapi": "5.19.0",
|
|
77
|
+
"@strapi/types": "5.19.0",
|
|
76
78
|
"@types/graphql-depth-limit": "1.1.5",
|
|
77
79
|
"@types/koa-bodyparser": "4.3.12",
|
|
78
80
|
"@types/koa__cors": "5.0.0",
|
|
79
81
|
"cross-env": "^7.0.3",
|
|
80
|
-
"eslint-config-custom": "5.
|
|
82
|
+
"eslint-config-custom": "5.19.0",
|
|
81
83
|
"koa": "2.16.1",
|
|
82
84
|
"react": "18.3.1",
|
|
83
85
|
"react-dom": "18.3.1",
|
|
84
86
|
"react-router-dom": "6.22.3",
|
|
85
87
|
"styled-components": "6.1.8",
|
|
86
|
-
"tsconfig": "5.
|
|
88
|
+
"tsconfig": "5.19.0",
|
|
87
89
|
"typescript": "5.4.4"
|
|
88
90
|
},
|
|
89
91
|
"peerDependencies": {
|