visitVariableDefinitionNode method

  1. @override
List<GraphQLError>? visitVariableDefinitionNode(
  1. VariableDefinitionNode node
)

Visit VariableDefinitionNode.

Implementation

@override
List<GraphQLError>? visitVariableDefinitionNode(VariableDefinitionNode node) {
  final type = convertTypeOrNull(node.type, schema.typeMap);

  if (type != null && !isInputType(type)) {
    return [
      GraphQLError(
        'Variable "\$${node.variable.name.value}" cannot'
        ' be non-input type "$type".',
        locations: GraphQLErrorLocation.listFromSource(
          node.span?.start ??
              node.type.span?.start ??
              node.variable.span?.start ??
              node.variable.name.span?.start,
        ),
        extensions: _variablesAreInputTypesSpec.extensions(),
      )
    ];
  }
}