@strapi/plugin-graphql 4.0.0 → 4.0.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/plugin-graphql",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Adds GraphQL endpoint with default API methods.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,13 +21,16 @@
|
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"test": "
|
|
24
|
+
"test:front": "cross-env IS_EE=true jest --config ./jest.config.front.js",
|
|
25
|
+
"test:front:watch": "cross-env IS_EE=true jest --config ./jest.config.front.js --watchAll",
|
|
26
|
+
"test:front:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js",
|
|
27
|
+
"test:front:watch:ce": "cross-env IS_EE=false jest --config ./jest.config.front.js --watchAll"
|
|
25
28
|
},
|
|
26
29
|
"dependencies": {
|
|
27
30
|
"@apollo/federation": "^0.28.0",
|
|
28
31
|
"@graphql-tools/schema": "8.1.2",
|
|
29
32
|
"@graphql-tools/utils": "^8.0.2",
|
|
30
|
-
"@strapi/utils": "4.0.
|
|
33
|
+
"@strapi/utils": "4.0.4",
|
|
31
34
|
"apollo-server-core": "3.1.2",
|
|
32
35
|
"apollo-server-koa": "3.1.2",
|
|
33
36
|
"glob": "^7.1.7",
|
|
@@ -37,7 +40,7 @@
|
|
|
37
40
|
"graphql-playground-middleware-koa": "^1.6.21",
|
|
38
41
|
"graphql-type-json": "^0.3.2",
|
|
39
42
|
"graphql-type-long": "^0.1.1",
|
|
40
|
-
"graphql-upload": "
|
|
43
|
+
"graphql-upload": "^13.0.0",
|
|
41
44
|
"koa-compose": "^4.1.0",
|
|
42
45
|
"lodash": "4.17.21",
|
|
43
46
|
"nexus": "1.1.0",
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
"koa": "^2.13.1"
|
|
50
53
|
},
|
|
51
54
|
"engines": {
|
|
52
|
-
"node": ">=12.
|
|
55
|
+
"node": ">=12.22.0 <=16.x.x",
|
|
53
56
|
"npm": ">=6.0.0"
|
|
54
57
|
},
|
|
55
58
|
"strapi": {
|
|
@@ -58,5 +61,5 @@
|
|
|
58
61
|
"description": "Adds GraphQL endpoint with default API methods.",
|
|
59
62
|
"kind": "plugin"
|
|
60
63
|
},
|
|
61
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "d81919ac2272948b3f5d3b25a4cf8cc7b6994460"
|
|
62
65
|
}
|
package/server/bootstrap.js
CHANGED
|
@@ -57,7 +57,7 @@ module.exports = async ({ strapi }) => {
|
|
|
57
57
|
bodyParserConfig: true,
|
|
58
58
|
|
|
59
59
|
plugins: [
|
|
60
|
-
process.env.NODE_ENV === 'production'
|
|
60
|
+
process.env.NODE_ENV === 'production' && !config('playgroundAlways')
|
|
61
61
|
? ApolloServerPluginLandingPageDisabled()
|
|
62
62
|
: ApolloServerPluginLandingPageGraphQLPlayground(),
|
|
63
63
|
],
|
|
@@ -58,8 +58,15 @@ module.exports = context => {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
validAttributes.forEach(([attributeName, attribute]) => {
|
|
61
|
+
// Enums
|
|
62
|
+
if (isEnumeration(attribute)) {
|
|
63
|
+
const enumTypeName = getEnumName(contentType, attributeName);
|
|
64
|
+
|
|
65
|
+
t.field(attributeName, { type: enumTypeName });
|
|
66
|
+
}
|
|
67
|
+
|
|
61
68
|
// Scalars
|
|
62
|
-
if (isStrapiScalar(attribute)) {
|
|
69
|
+
else if (isStrapiScalar(attribute)) {
|
|
63
70
|
const gqlScalar = mappers.strapiScalarToGraphQLScalar(attribute.type);
|
|
64
71
|
|
|
65
72
|
t.field(attributeName, { type: gqlScalar });
|
|
@@ -87,13 +94,6 @@ module.exports = context => {
|
|
|
87
94
|
isToManyRelation ? t.list.id(attributeName) : t.id(attributeName);
|
|
88
95
|
}
|
|
89
96
|
|
|
90
|
-
// Enums
|
|
91
|
-
else if (isEnumeration(attribute)) {
|
|
92
|
-
const enumTypeName = getEnumName(contentType, attributeName);
|
|
93
|
-
|
|
94
|
-
t.field(attributeName, { type: enumTypeName });
|
|
95
|
-
}
|
|
96
|
-
|
|
97
97
|
// Components
|
|
98
98
|
else if (isComponent(attribute)) {
|
|
99
99
|
const isRepeatable = attribute.repeatable === true;
|
|
@@ -322,8 +322,13 @@ module.exports = context => {
|
|
|
322
322
|
*/
|
|
323
323
|
const options = { builder, attributeName, attribute, contentType, context };
|
|
324
324
|
|
|
325
|
+
// Enums
|
|
326
|
+
if (isEnumeration(attribute)) {
|
|
327
|
+
addEnumAttribute(options);
|
|
328
|
+
}
|
|
329
|
+
|
|
325
330
|
// Scalars
|
|
326
|
-
if (isStrapiScalar(attribute)) {
|
|
331
|
+
else if (isStrapiScalar(attribute)) {
|
|
327
332
|
addScalarAttribute(options);
|
|
328
333
|
}
|
|
329
334
|
|
|
@@ -337,11 +342,6 @@ module.exports = context => {
|
|
|
337
342
|
addDynamicZoneAttribute(options);
|
|
338
343
|
}
|
|
339
344
|
|
|
340
|
-
// Enums
|
|
341
|
-
else if (isEnumeration(attribute)) {
|
|
342
|
-
addEnumAttribute(options);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
345
|
// Media
|
|
346
346
|
else if (isMedia(attribute)) {
|
|
347
347
|
addMediaAttribute(options);
|
|
@@ -24,6 +24,7 @@ const STRAPI_SCALARS = [
|
|
|
24
24
|
'integer',
|
|
25
25
|
'string',
|
|
26
26
|
'richtext',
|
|
27
|
+
'enumeration',
|
|
27
28
|
'biginteger',
|
|
28
29
|
'float',
|
|
29
30
|
'decimal',
|
|
@@ -46,6 +47,7 @@ const SCALARS_ASSOCIATIONS = {
|
|
|
46
47
|
boolean: 'Boolean',
|
|
47
48
|
integer: 'Int',
|
|
48
49
|
string: 'String',
|
|
50
|
+
enumeration: 'String',
|
|
49
51
|
richtext: 'String',
|
|
50
52
|
biginteger: 'Long',
|
|
51
53
|
float: 'Float',
|
|
@@ -23,11 +23,12 @@ module.exports = ({ strapi }) => {
|
|
|
23
23
|
async resolve(parent) {
|
|
24
24
|
const { args, resourceUID } = parent;
|
|
25
25
|
const { start, limit } = args;
|
|
26
|
+
const safeLimit = Math.max(limit, 1);
|
|
26
27
|
|
|
27
28
|
const total = await strapi.entityService.count(resourceUID, args);
|
|
28
|
-
const pageSize = limit;
|
|
29
|
-
const pageCount = limit ===
|
|
30
|
-
const page = limit ===
|
|
29
|
+
const pageSize = limit === -1 ? total - start : safeLimit;
|
|
30
|
+
const pageCount = limit === -1 ? safeLimit : Math.ceil(total / safeLimit);
|
|
31
|
+
const page = limit === -1 ? safeLimit : Math.floor(start / safeLimit) + 1;
|
|
31
32
|
|
|
32
33
|
return { total, page, pageSize, pageCount };
|
|
33
34
|
},
|