neo4j-php-client icon indicating copy to clipboard operation
neo4j-php-client copied to clipboard

Use bookmarks in basic formatter

Open transistive opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe. I simply forgot to implement bookmarks if you use the basic formatter.

Describe the solution you'd like Implement it like the other formatter

Additional context Pointed out by the lovely folks over at issue #139, @stefanak-michal and @wgevaert

transistive avatar Jul 27 '22 20:07 transistive

Would it be possible to set the return type of FormatterInterface::formatBoltResult to CypherList and then put the following code from OGMFormatter in BoltUnmanagedTransaction:

        $result = new BoltResult(...);
        $formattedResult = $this->formatter->formatBoltResult(...,$result,...);

        $this->connection->subscribeResult($formattedResult);
        $result->addFinishedCallback(function (array $response) {
            if (array_key_exists('bookmark', $response) && is_string($response['bookmark'])) {
                $this->bookmarkHolder->setBookmark(new Bookmark([$response['bookmark']]));
            }
        });
        return $formattedResult;

or would this do stupid things for e.g. the summarisedresultformatter?

This way, we only use the formatter for actual formatting, and do the other not-strictly-formatter operations outside of the formatter.

EDIT: Or maybe you want the addFinishedCallback before the formatter?

wgevaert avatar Aug 09 '22 14:08 wgevaert