createRelation method

  1. @override
Future<WriteResult> createRelation(
  1. String resourceKey,
  2. Object id,
  3. RelationDescriptor relation,
  4. Map<String, dynamic> values,
)
override

The three relation-row writes (P9) sit beside relation, the read: same sibling URL family, same never-throw contract as create/update/destroy — a 4xx comes back as data and only a transport failure throws, which the catch folds into WriteFailed exactly the way those three do.

Implementation

@override
Future<WriteResult> createRelation(
  String resourceKey,
  Object id,
  RelationDescriptor relation,
  Map<String, dynamic> values,
) async {
  try {
    return _interpret(
      await _transport.post(
        '$prefix/$resourceKey/$id/relations/${relation.key}',
        values,
      ),
    );
  } catch (e) {
    return WriteFailed(messageOf(e));
  }
}