def dump_relation(api, rel_cfg, pid, data):
    """Dump a specific relation to a data dict."""
    schema_class = rel_cfg.schema
    if schema_class is not None:
        schema = schema_class()
        schema.context['pid'] = pid
        result, errors = schema.dump(api)
        data.setdefault(rel_cfg.name, []).append(result)