Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/query-validation-visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = class QueryValidationVisitor {

validateInputTypeValue(this.context, inputObjectTypeDef, argName, variableName, value, this.currentField, variableName, this.options)
} else if (isListType(valueTypeDef)) {
validateArrayTypeValue(this.context, valueTypeDef, argTypeDef, value, this.currentField, argName, variableName, variableName)
validateArrayTypeValue(this.context, valueTypeDef, argTypeDef, value, this.currentField, argName, variableName, variableName, this.options)
} else {
// nothing to validate
if (!value && value !== '' && value !== 0) return
Expand Down Expand Up @@ -184,7 +184,7 @@ function validateInputTypeValue (context, inputObjectTypeDef, argName, variableN
visit(inputObjectTypeDef.astNode, visitor)
}

function validateArrayTypeValue (context, valueTypeDef, typeDefWithDirective, value, currentField, argName, variableName, iFieldNameFull) {
function validateArrayTypeValue (context, valueTypeDef, typeDefWithDirective, value, currentField, argName, variableName, iFieldNameFull, options) {
if (!typeDefWithDirective.astNode) { return }

let valueTypeDefArray = valueTypeDef.ofType
Expand Down Expand Up @@ -228,13 +228,11 @@ function validateArrayTypeValue (context, valueTypeDef, typeDefWithDirective, va
if (value) {
value.forEach((element, index) => {
const iFieldNameFullIndexed = iFieldNameFull ? `${iFieldNameFull}[${index++}]` : `[${index++}]`

if (isInputObjectType(valueTypeDefArray)) {
validateInputTypeValue(context, valueTypeDefArray, argName, variableName, element, currentField, iFieldNameFullIndexed, this.options)
validateInputTypeValue(context, valueTypeDefArray, argName, variableName, element, currentField, iFieldNameFullIndexed, options ?? this.options)
} else if (hasNonListValidation) {
const atMessage = ` at "${iFieldNameFullIndexed}"`

validateScalarTypeValue(context, currentField, typeDefWithDirective, valueTypeDef, element, variableName, argName, iFieldNameFullIndexed, atMessage, this.options)
validateScalarTypeValue(context, currentField, typeDefWithDirective, valueTypeDef, element, variableName, argName, iFieldNameFullIndexed, atMessage, options ?? this.options)
}
})
}
Expand Down Expand Up @@ -276,7 +274,7 @@ class InputObjectValidationVisitor {

validateInputTypeValue(this.context, valueTypeDef, this.argName, this.variableName, value, this.currentField, iFieldNameFull, this.options)
} else if (isListType(valueTypeDef)) {
validateArrayTypeValue(this.context, valueTypeDef, iFieldTypeDef, value, this.currentField, this.argName, this.variableName, iFieldNameFull)
validateArrayTypeValue(this.context, valueTypeDef, iFieldTypeDef, value, this.currentField, this.argName, this.variableName, iFieldNameFull, this.options)
} else {
// nothing to validate
if (!value && value !== '' && value !== 0) return
Expand Down