getFieldAnnot function
GraphQLField
getFieldAnnot(
- GraphQLObject? clazz,
- Element e
Implementation
GraphQLField getFieldAnnot(GraphQLObject? clazz, Element e) {
const graphQLFieldTypeChecker = TypeChecker.fromRuntime(GraphQLField);
// TODO: remove this
// ignore: unused_local_variable
DartObject? _annot;
if (!graphQLFieldTypeChecker.hasAnnotationOf(e, throwOnUnresolved: false)) {
if (e is FieldElement && e.getter != null) {
return getFieldAnnot(clazz, e.getter!);
} else if (e is ParameterElement) {
_annot = e.metadata.firstWhereOrNull(
(element) {
final type = element.computeConstantValue()?.type;
return type != null && graphQLFieldTypeChecker.isExactlyType(type);
},
)?.computeConstantValue();
// if (_annot == null) {
// return const GraphQLField();
// }
}
}
final annot = graphQLFieldTypeChecker.firstAnnotationOf(
e,
throwOnUnresolved: false,
);
final name = annot?.getField('name')?.toStringValue();
final omit = annot?.getField('omit')?.toBoolValue();
final nullable = annot?.getField('nullable')?.toBoolValue();
final type = annot?.getField('type')?.toStringValue();
return GraphQLField(
name: name,
omit: omit ?? clazz?.omitFields,
nullable: nullable ?? clazz?.nullableFields,
type: type,
);
}