fromNode method Null safety

TypeDefinition fromNode(
  1. TypeDefinitionNode node
)

Implementation

static TypeDefinition fromNode(TypeDefinitionNode node) {
  if (node is ScalarTypeDefinitionNode) {
    return ScalarTypeDefinition(node);
  }

  if (node is InterfaceTypeDefinitionNode) {
    return InterfaceTypeDefinition(node);
  }

  if (node is ObjectTypeDefinitionNode) {
    return ObjectTypeDefinition(node);
  }

  if (node is UnionTypeDefinitionNode) {
    return UnionTypeDefinition(node);
  }

  if (node is EnumTypeDefinitionNode) {
    return EnumTypeDefinition(node);
  }

  if (node is InputObjectTypeDefinitionNode) {
    return InputObjectTypeDefinition(node);
  }

  /*
  https://github.com/graphql/graphql-js/blob/49d86bbc810d1203aa3f7d93252e51f257d9460f/src/language/predicates.js#L59
  doesn't include enum values
  if (node is EnumValueDefinitionNode) {
    return EnumValueDefinition.fromNode(node);
  }
  */

  throw ArgumentError("$node is unsupported");
}