@@ -23,15 +23,15 @@ class TypeValidationError extends Error {
23
23
}
24
24
}
25
25
26
- const parseStringValue = value => {
26
+ const parseStringValue = ( value ) => {
27
27
if ( typeof value === 'string' ) {
28
28
return value ;
29
29
}
30
30
31
31
throw new TypeValidationError ( value , 'String' ) ;
32
32
} ;
33
33
34
- const parseIntValue = value => {
34
+ const parseIntValue = ( value ) => {
35
35
if ( typeof value === 'string' ) {
36
36
const int = Number ( value ) ;
37
37
if ( Number . isInteger ( int ) ) {
@@ -42,7 +42,7 @@ const parseIntValue = value => {
42
42
throw new TypeValidationError ( value , 'Int' ) ;
43
43
} ;
44
44
45
- const parseFloatValue = value => {
45
+ const parseFloatValue = ( value ) => {
46
46
if ( typeof value === 'string' ) {
47
47
const float = Number ( value ) ;
48
48
if ( ! isNaN ( float ) ) {
@@ -53,15 +53,15 @@ const parseFloatValue = value => {
53
53
throw new TypeValidationError ( value , 'Float' ) ;
54
54
} ;
55
55
56
- const parseBooleanValue = value => {
56
+ const parseBooleanValue = ( value ) => {
57
57
if ( typeof value === 'boolean' ) {
58
58
return value ;
59
59
}
60
60
61
61
throw new TypeValidationError ( value , 'Boolean' ) ;
62
62
} ;
63
63
64
- const parseValue = value => {
64
+ const parseValue = ( value ) => {
65
65
switch ( value . kind ) {
66
66
case Kind . STRING :
67
67
return parseStringValue ( value . value ) ;
@@ -86,15 +86,15 @@ const parseValue = value => {
86
86
}
87
87
} ;
88
88
89
- const parseListValues = values => {
89
+ const parseListValues = ( values ) => {
90
90
if ( Array . isArray ( values ) ) {
91
- return values . map ( value => parseValue ( value ) ) ;
91
+ return values . map ( ( value ) => parseValue ( value ) ) ;
92
92
}
93
93
94
94
throw new TypeValidationError ( values , 'List' ) ;
95
95
} ;
96
96
97
- const parseObjectFields = fields => {
97
+ const parseObjectFields = ( fields ) => {
98
98
if ( Array . isArray ( fields ) ) {
99
99
return fields . reduce (
100
100
( object , field ) => ( {
@@ -112,9 +112,9 @@ const ANY = new GraphQLScalarType({
112
112
name : 'Any' ,
113
113
description :
114
114
'The Any scalar type is used in operations and types that involve any type of value.' ,
115
- parseValue : value => value ,
116
- serialize : value => value ,
117
- parseLiteral : ast => parseValue ( ast ) ,
115
+ parseValue : ( value ) => value ,
116
+ serialize : ( value ) => value ,
117
+ parseLiteral : ( ast ) => parseValue ( ast ) ,
118
118
} ) ;
119
119
120
120
const OBJECT = new GraphQLScalarType ( {
@@ -144,7 +144,7 @@ const OBJECT = new GraphQLScalarType({
144
144
} ,
145
145
} ) ;
146
146
147
- const parseDateIsoValue = value => {
147
+ const parseDateIsoValue = ( value ) => {
148
148
if ( typeof value === 'string' ) {
149
149
const date = new Date ( value ) ;
150
150
if ( ! isNaN ( date ) ) {
@@ -157,7 +157,7 @@ const parseDateIsoValue = value => {
157
157
throw new TypeValidationError ( value , 'Date' ) ;
158
158
} ;
159
159
160
- const serializeDateIso = value => {
160
+ const serializeDateIso = ( value ) => {
161
161
if ( typeof value === 'string' ) {
162
162
return value ;
163
163
}
@@ -168,7 +168,7 @@ const serializeDateIso = value => {
168
168
throw new TypeValidationError ( value , 'Date' ) ;
169
169
} ;
170
170
171
- const parseDateIsoLiteral = ast => {
171
+ const parseDateIsoLiteral = ( ast ) => {
172
172
if ( ast . kind === Kind . STRING ) {
173
173
return parseDateIsoValue ( ast . value ) ;
174
174
}
@@ -219,8 +219,8 @@ const DATE = new GraphQLScalarType({
219
219
iso : parseDateIsoLiteral ( ast ) ,
220
220
} ;
221
221
} else if ( ast . kind === Kind . OBJECT ) {
222
- const __type = ast . fields . find ( field => field . name . value === '__type' ) ;
223
- const iso = ast . fields . find ( field => field . name . value === 'iso' ) ;
222
+ const __type = ast . fields . find ( ( field ) => field . name . value === '__type' ) ;
223
+ const iso = ast . fields . find ( ( field ) => field . name . value === 'iso' ) ;
224
224
if ( __type && __type . value && __type . value . value === 'Date' && iso ) {
225
225
return {
226
226
__type : __type . value . value ,
@@ -273,8 +273,8 @@ const BYTES = new GraphQLScalarType({
273
273
base64 : ast . value ,
274
274
} ;
275
275
} else if ( ast . kind === Kind . OBJECT ) {
276
- const __type = ast . fields . find ( field => field . name . value === '__type' ) ;
277
- const base64 = ast . fields . find ( field => field . name . value === 'base64' ) ;
276
+ const __type = ast . fields . find ( ( field ) => field . name . value === '__type' ) ;
277
+ const base64 = ast . fields . find ( ( field ) => field . name . value === 'base64' ) ;
278
278
if (
279
279
__type &&
280
280
__type . value &&
@@ -294,7 +294,7 @@ const BYTES = new GraphQLScalarType({
294
294
} ,
295
295
} ) ;
296
296
297
- const parseFileValue = value => {
297
+ const parseFileValue = ( value ) => {
298
298
if ( typeof value === 'string' ) {
299
299
return {
300
300
__type : 'File' ,
@@ -317,7 +317,7 @@ const FILE = new GraphQLScalarType({
317
317
description :
318
318
'The File scalar type is used in operations and types that involve files.' ,
319
319
parseValue : parseFileValue ,
320
- serialize : value => {
320
+ serialize : ( value ) => {
321
321
if ( typeof value === 'string' ) {
322
322
return value ;
323
323
} else if (
@@ -335,9 +335,9 @@ const FILE = new GraphQLScalarType({
335
335
if ( ast . kind === Kind . STRING ) {
336
336
return parseFileValue ( ast . value ) ;
337
337
} else if ( ast . kind === Kind . OBJECT ) {
338
- const __type = ast . fields . find ( field => field . name . value === '__type' ) ;
339
- const name = ast . fields . find ( field => field . name . value === 'name' ) ;
340
- const url = ast . fields . find ( field => field . name . value === 'url' ) ;
338
+ const __type = ast . fields . find ( ( field ) => field . name . value === '__type' ) ;
339
+ const name = ast . fields . find ( ( field ) => field . name . value === 'name' ) ;
340
+ const url = ast . fields . find ( ( field ) => field . name . value === 'url' ) ;
341
341
if ( __type && __type . value && name && name . value ) {
342
342
return parseFileValue ( {
343
343
__type : __type . value . value ,
@@ -371,13 +371,19 @@ const FILE_INPUT = new GraphQLInputObjectType({
371
371
name : 'FileInput' ,
372
372
fields : {
373
373
file : {
374
- description : 'A File Scalar can be an url or a FileInfo object.' ,
374
+ description :
375
+ 'A File Scalar can be an url or a FileInfo object. If this field is set to null the file will be unlinked.' ,
375
376
type : FILE ,
376
377
} ,
377
378
upload : {
378
379
description : 'Use this field if you want to create a new file.' ,
379
380
type : GraphQLUpload ,
380
381
} ,
382
+ unlink : {
383
+ description :
384
+ 'Use this field if you want to unlink the file (the file will not be deleted on cloud storage)' ,
385
+ type : GraphQLBoolean ,
386
+ } ,
381
387
} ,
382
388
} ) ;
383
389
@@ -551,7 +557,7 @@ const ACL = new GraphQLObjectType({
551
557
type : new GraphQLList ( new GraphQLNonNull ( USER_ACL ) ) ,
552
558
resolve ( p ) {
553
559
const users = [ ] ;
554
- Object . keys ( p ) . forEach ( rule => {
560
+ Object . keys ( p ) . forEach ( ( rule ) => {
555
561
if ( rule !== '*' && rule . indexOf ( 'role:' ) !== 0 ) {
556
562
users . push ( {
557
563
userId : toGlobalId ( '_User' , rule ) ,
@@ -568,7 +574,7 @@ const ACL = new GraphQLObjectType({
568
574
type : new GraphQLList ( new GraphQLNonNull ( ROLE_ACL ) ) ,
569
575
resolve ( p ) {
570
576
const roles = [ ] ;
571
- Object . keys ( p ) . forEach ( rule => {
577
+ Object . keys ( p ) . forEach ( ( rule ) => {
572
578
if ( rule . indexOf ( 'role:' ) === 0 ) {
573
579
roles . push ( {
574
580
roleName : rule . replace ( 'role:' , '' ) ,
@@ -839,49 +845,49 @@ const GEO_INTERSECTS_INPUT = new GraphQLInputObjectType({
839
845
} ,
840
846
} ) ;
841
847
842
- const equalTo = type => ( {
848
+ const equalTo = ( type ) => ( {
843
849
description :
844
850
'This is the equalTo operator to specify a constraint to select the objects where the value of a field equals to a specified value.' ,
845
851
type,
846
852
} ) ;
847
853
848
- const notEqualTo = type => ( {
854
+ const notEqualTo = ( type ) => ( {
849
855
description :
850
856
'This is the notEqualTo operator to specify a constraint to select the objects where the value of a field do not equal to a specified value.' ,
851
857
type,
852
858
} ) ;
853
859
854
- const lessThan = type => ( {
860
+ const lessThan = ( type ) => ( {
855
861
description :
856
862
'This is the lessThan operator to specify a constraint to select the objects where the value of a field is less than a specified value.' ,
857
863
type,
858
864
} ) ;
859
865
860
- const lessThanOrEqualTo = type => ( {
866
+ const lessThanOrEqualTo = ( type ) => ( {
861
867
description :
862
868
'This is the lessThanOrEqualTo operator to specify a constraint to select the objects where the value of a field is less than or equal to a specified value.' ,
863
869
type,
864
870
} ) ;
865
871
866
- const greaterThan = type => ( {
872
+ const greaterThan = ( type ) => ( {
867
873
description :
868
874
'This is the greaterThan operator to specify a constraint to select the objects where the value of a field is greater than a specified value.' ,
869
875
type,
870
876
} ) ;
871
877
872
- const greaterThanOrEqualTo = type => ( {
878
+ const greaterThanOrEqualTo = ( type ) => ( {
873
879
description :
874
880
'This is the greaterThanOrEqualTo operator to specify a constraint to select the objects where the value of a field is greater than or equal to a specified value.' ,
875
881
type,
876
882
} ) ;
877
883
878
- const inOp = type => ( {
884
+ const inOp = ( type ) => ( {
879
885
description :
880
886
'This is the in operator to specify a constraint to select the objects where the value of a field equals any value in the specified array.' ,
881
887
type : new GraphQLList ( type ) ,
882
888
} ) ;
883
889
884
- const notIn = type => ( {
890
+ const notIn = ( type ) => ( {
885
891
description :
886
892
'This is the notIn operator to specify a constraint to select the objects where the value of a field do not equal any value in the specified array.' ,
887
893
type : new GraphQLList ( type ) ,
@@ -1219,14 +1225,14 @@ let ARRAY_RESULT;
1219
1225
1220
1226
const loadArrayResult = ( parseGraphQLSchema , parseClasses ) => {
1221
1227
const classTypes = parseClasses
1222
- . filter ( parseClass =>
1228
+ . filter ( ( parseClass ) =>
1223
1229
parseGraphQLSchema . parseClassTypes [ parseClass . className ]
1224
1230
. classGraphQLOutputType
1225
1231
? true
1226
1232
: false
1227
1233
)
1228
1234
. map (
1229
- parseClass =>
1235
+ ( parseClass ) =>
1230
1236
parseGraphQLSchema . parseClassTypes [ parseClass . className ]
1231
1237
. classGraphQLOutputType
1232
1238
) ;
@@ -1235,7 +1241,7 @@ const loadArrayResult = (parseGraphQLSchema, parseClasses) => {
1235
1241
description :
1236
1242
'Use Inline Fragment on Array to get results: https://graphql.org/learn/queries/#inline-fragments' ,
1237
1243
types : ( ) => [ ELEMENT , ...classTypes ] ,
1238
- resolveType : value => {
1244
+ resolveType : ( value ) => {
1239
1245
if ( value . __type === 'Object' && value . className && value . objectId ) {
1240
1246
if ( parseGraphQLSchema . parseClassTypes [ value . className ] ) {
1241
1247
return parseGraphQLSchema . parseClassTypes [ value . className ]
@@ -1251,7 +1257,7 @@ const loadArrayResult = (parseGraphQLSchema, parseClasses) => {
1251
1257
parseGraphQLSchema . graphQLTypes . push ( ARRAY_RESULT ) ;
1252
1258
} ;
1253
1259
1254
- const load = parseGraphQLSchema => {
1260
+ const load = ( parseGraphQLSchema ) => {
1255
1261
parseGraphQLSchema . addGraphQLType ( GraphQLUpload , true ) ;
1256
1262
parseGraphQLSchema . addGraphQLType ( ANY , true ) ;
1257
1263
parseGraphQLSchema . addGraphQLType ( OBJECT , true ) ;
0 commit comments