0
def get_nlg(graph_query):
    driver = Graph("neo4j://localhost:7687", auth=("neo4j","password"))
    graph_response = graph.evaluate(graph_query)

For the above code, I replaced with the driver code as below, but its not working, what is the function in neo4j driver equivalent to evaluate() function in py2neo?

    def get_nlg(graph_query):
        driver = GraphDatabase.driver("neo4j://localhost:7687", auth=("neo4j","password"))

        with driver.session() as session:
            graph_response = session.run(graph_query)
            return graph_response

When the result from graph_response of 2nd code is passed to the below code, I am getting an error

TypeError: <neo4j.work.result.Result object at 0x7f94cf7f31d0> is not JSON serializable

class GetBiggestComponent(Action):
    def name(self):
        return "action_get_biggest_component"

    def run(self, dispatcher, tracker, domain):
        query = None
        intent = tracker.latest_message['intent']
        child_comp = tracker.get_slot('component_type_child')
        parent_comp = tracker.get_slot('component_type_parent')
        error = None
        graph_response = GenerateQuery.get_biggest_component(child_comp, parent_comp)
        graph_response['intent_name'] = intent['name']
        dispatcher.utter_message(json.dumps(graph_response))
        return []

the error is coming when it is passed in the line

dispatcher.utter_message(json.dumps(graph_response))
James Z
  • 12,209
  • 10
  • 24
  • 44
  • Don't post duplicate questions: https://stackoverflow.com/questions/64800042/neo4j-driver-functions-equivalent-to-py2neo-functions – James Z Nov 18 '20 at 15:49

1 Answers1

0

The output of session.run is an object that lets you navigate the result, not the result itself. I strongly recommend reading the manual and API docs for the driver, as this is all described in there.

As per my answer to your other question, to simulate evaluate, you will simply need to navigate to the first record of the result and then return the first value of that record.

Nigel Small
  • 4,475
  • 1
  • 17
  • 15