inputTypeAnnotation function

GraphQLInput? inputTypeAnnotation(
  1. Element elem
)

Implementation

GraphQLInput? inputTypeAnnotation(Element elem) {
  final _isInput =
      const TypeChecker.fromRuntime(GraphQLInput).firstAnnotationOfExact(elem);
  if (_isInput != null && (elem is! ClassElement || !hasFromJson(elem))) {
    throw Exception(
      'A class annotated with GraphQLInput'
      ' should have a fromJson static method or constructor.',
    );
  }
  return _isInput == null
      ? null
      : GraphQLInput(
          name: _isInput.getField('name')?.toStringValue(),
          constructor: _isInput.getField('constructor')?.toStringValue(),
          oneOf: _isInput.getField('oneOf')?.toBoolValue(),
        );
}