getTypeByName function
TypeDefinitionNode
getTypeByName(
- TypeDefinitionNodeVisitor typeDefinitionNodeVisitor,
- TypeNode typeNode
Get a full TypeDefinitionNode
from a type node.
Implementation
TypeDefinitionNode getTypeByName(
TypeDefinitionNodeVisitor typeDefinitionNodeVisitor,
TypeNode typeNode,
) {
late NamedTypeNode namedNode;
if (typeNode is ListTypeNode) {
return getTypeByName(typeDefinitionNodeVisitor, typeNode.type);
}
if (typeNode is NamedTypeNode) {
namedNode = typeNode;
}
final type = typeDefinitionNodeVisitor.getByName(namedNode.name.value);
if (type == null) {
throw Exception('''Type ${namedNode.name.value} was not found in schema.
Make sure your query is correct and your schema is updated.''');
}
return type;
}