generateGraphqlDefinition method
String
generateGraphqlDefinition(
- FieldElement field
)
Implementation
String generateGraphqlDefinition(FieldElement field) {
final annotation = fields.annotationForField(field);
final checker = checkerForType(field.type);
final remoteName = providerNameForField(annotation.name, checker: checker);
final columnInsertionType = checker.withoutNullResultType;
final subfields = (annotation.subfields ?? _subfieldsForType(field.type))
.entries
.fold<List<String>>(<String>[], (acc, entry) {
acc.add(_convertMapToString(entry));
return acc;
}).join(',');
// T0D0 support List<Future<Sibling>> for 'association'
return '''
'${field.name}': const RuntimeGraphqlDefinition(
association: ${checker.isSibling || (checker.isIterable && checker.isArgTypeASibling)},
documentNodeName: '$remoteName',
iterable: ${checker.isIterable},
subfields: <String, Map<String, dynamic>>{$subfields},
type: $columnInsertionType,
)
''';
}