def METHOD_NAME(
    self,
    ctx: rest.Context,
    entity_id: int,
    serializer: Callable[[model.Base], rest.Response],
) -> rest.Response:
    entities = self.get_around(
        ctx.get_param_as_string("query", default=""), entity_id
    )
    return {
        "prev": serializer(entities[0]),
        "next": serializer(entities[1]),
    }