getDocumentation function

GraphQLDocumentation? getDocumentation(
  1. Element element
)

Implementation

GraphQLDocumentation? getDocumentation(Element element) {
  final annot = graphQLDocTypeChecker.firstAnnotationOfExact(element);

  if (annot != null) {
    final typeFunc = annot.getField('type')?.toFunctionValue();
    final _typeName = annot.getField('typeName')?.toStringValue();
    if (typeFunc != null && _typeName != null) {
      throw Exception(
        "Can't have both type $typeFunc and typeName $_typeName set"
        ' in $GraphQLDocumentation, please use only one of them.',
      );
    }
    final _typeFunc =
        typeFunc == null ? null : executeCodeForExecutable(typeFunc);
    return GraphQLDocumentation(
      description: annot.getField('description')?.toStringValue(),
      deprecationReason: annot.getField('deprecationReason')?.toStringValue(),
      typeName: _typeName ?? _typeFunc,
    );
  }
  return null;
}