@@ -254,9 +254,15 @@ class GraphqlFieldDefinitionMethodCall extends GraphqlSchemaObjectClassMethodCal
254
254
/** Gets the name of this GraphQL field. */
255
255
string getFieldName ( ) { result = this .getArgument ( 0 ) .getConstantValue ( ) .getStringlikeValue ( ) }
256
256
257
+ /**
258
+ * Gets the type of this field.
259
+ */
257
260
GraphqlType getFieldType ( ) { result = this .getArgument ( 1 ) }
258
261
259
- GraphqlFieldArgumentDefinitionMethodCall getArgumentCall ( ) {
262
+ /**
263
+ * Gets an argument call inside this field definition.
264
+ */
265
+ GraphqlFieldArgumentDefinitionMethodCall getAnArgumentCall ( ) {
260
266
result .getEnclosingCallable ( ) = this .getBlock ( )
261
267
}
262
268
}
@@ -300,20 +306,20 @@ private class GraphqlFieldArgumentDefinitionMethodCall extends GraphqlSchemaObje
300
306
GraphqlType getArgumentType ( ) { result = this .getArgument ( 1 ) }
301
307
}
302
308
303
- private DataFlow:: LocalSourceNode graphQlEnum ( ) {
304
- result =
305
- API:: getTopLevelMember ( "GraphQL" )
306
- .getMember ( "Schema" )
307
- .getMember ( "Enum" )
308
- .getADescendentModule ( )
309
- .getAnImmediateReference ( )
310
- }
311
-
312
309
private class GraphqlType extends ConstantAccess {
310
+ /**
311
+ * Gets the module corresponding to this type, if it exists.
312
+ */
313
313
Module getModule ( ) { result .getAnImmediateReference ( ) = this }
314
314
315
+ /**
316
+ * Gets a field of this type, if it is an object type.
317
+ */
315
318
GraphqlType getAField ( ) { result = this .getField ( _) }
316
319
320
+ /**
321
+ * Gets the field of this type named `name`, if it exists.
322
+ */
317
323
GraphqlType getField ( string name ) {
318
324
result =
319
325
any ( GraphqlFieldDefinitionMethodCall field |
@@ -322,10 +328,22 @@ private class GraphqlType extends ConstantAccess {
322
328
) .getFieldType ( )
323
329
}
324
330
325
- predicate isEnum ( ) { graphQlEnum ( ) .asExpr ( ) .getExpr ( ) = this }
326
-
327
- predicate isUserControlled ( ) { this .getName ( ) = [ "String" , "ID" , "JSON" ] }
331
+ /**
332
+ * Holds if this type is an enum.
333
+ */
334
+ predicate isEnum ( ) {
335
+ API:: getTopLevelMember ( "GraphQL" )
336
+ .getMember ( "Schema" )
337
+ .getMember ( "Enum" )
338
+ .getADescendentModule ( )
339
+ .getAnImmediateReference ( )
340
+ .asExpr ( )
341
+ .getExpr ( ) = this
342
+ }
328
343
344
+ /**
345
+ * Holds if this type is scalar - i.e. it is neither an object or an enum.
346
+ */
329
347
predicate isScalar ( ) { not exists ( this .getAField ( ) ) and not this .isEnum ( ) }
330
348
}
331
349
@@ -401,7 +419,7 @@ class GraphqlFieldResolutionMethod extends Method, Http::Server::RequestHandler:
401
419
override Parameter getARoutedParameter ( ) {
402
420
result = this .getAParameter ( ) and
403
421
exists ( GraphqlFieldArgumentDefinitionMethodCall argDefn |
404
- argDefn = this .getDefinition ( ) .getArgumentCall ( )
422
+ argDefn = this .getDefinition ( ) .getAnArgumentCall ( )
405
423
|
406
424
result .( KeywordParameter ) .hasName ( argDefn .getArgumentName ( ) )
407
425
)
@@ -426,7 +444,7 @@ private DataFlow::CallNode parameterAccess(
426
444
HashSplatParameter param , string key , GraphqlType type
427
445
) {
428
446
param = method .getARoutedParameter ( ) and
429
- def = method .getDefinition ( ) .getArgumentCall ( ) and
447
+ def = method .getDefinition ( ) .getAnArgumentCall ( ) and
430
448
(
431
449
// Direct access to the params hash
432
450
def .getArgumentType ( ) = type and
0 commit comments