@@ -3,6 +3,7 @@ local types = require(path .. '.types')
3
3
local util = require (path .. ' .util' )
4
4
local schema = require (path .. ' .schema' )
5
5
local introspection = require (path .. ' .introspection' )
6
+ local query_util = require (path .. ' .query_util' )
6
7
7
8
local function getParentField (context , name , count )
8
9
if introspection .fieldMap [name ] then return introspection .fieldMap [name ] end
@@ -490,21 +491,8 @@ function rules.variableUsageAllowed(node, context)
490
491
local variableDefinition = variableMap [variableName ]
491
492
local hasDefault = variableDefinition .defaultValue ~= nil
492
493
493
- local function typeFromAST (variable )
494
- local innerType
495
- if variable .kind == ' listType' then
496
- innerType = typeFromAST (variable .type )
497
- return innerType and types .list (innerType )
498
- elseif variable .kind == ' nonNullType' then
499
- innerType = typeFromAST (variable .type )
500
- return innerType and types .nonNull (innerType )
501
- else
502
- assert (variable .kind == ' namedType' , ' Variable must be a named type' )
503
- return context .schema :getType (variable .name .value )
504
- end
505
- end
506
-
507
- local variableType = typeFromAST (variableDefinition .type )
494
+ local variableType = query_util .typeFromAST (variableDefinition .type ,
495
+ context .schema )
508
496
509
497
if hasDefault and variableType .__type ~= ' NonNull' then
510
498
variableType = types .nonNull (variableType )
0 commit comments