**Retrieves data about a node in the graph, based on node ID.** :param **node_id** (str) - node id, used for indexed search :returns: Node response, with node id, labels, and properties.
(node_id: int, current_user: User = Depends(get_current_active_user))
| 76 | # READ data about a node in the graph by ID |
| 77 | @router.get('/read/{node_id}', response_model=Node) |
| 78 | async def read_node_id(node_id: int, current_user: User = Depends(get_current_active_user)): |
| 79 | """ |
| 80 | **Retrieves data about a node in the graph, based on node ID.** |
| 81 | |
| 82 | :param **node_id** (str) - node id, used for indexed search |
| 83 | |
| 84 | :returns: Node response, with node id, labels, and properties. |
| 85 | """ |
| 86 | |
| 87 | cypher = """ |
| 88 | MATCH (node) |
| 89 | WHERE ID(node) = $node_id |
| 90 | RETURN ID(node) as id, LABELS(node) as labels, node |
| 91 | """ |
| 92 | |
| 93 | with neo4j_driver.session() as session: |
| 94 | result = session.run(query=cypher, |
| 95 | parameters={'node_id': node_id}) |
| 96 | |
| 97 | node_data = result.data()[0] |
| 98 | |
| 99 | # Check node for type User, and send error message if needed |
| 100 | if 'User' in node_data['labels']: |
| 101 | raise HTTPException( |
| 102 | status_code=status.HTTP_422_UNPROCESSABLE_ENTITY, |
| 103 | detail="Operation not permitted, please use User endpoints to retrieve user information.", |
| 104 | headers={"WWW-Authenticate": "Bearer"}) |
| 105 | |
| 106 | # Return Node response |
| 107 | return Node(node_id=node_data['id'], |
| 108 | labels=node_data['labels'], |
| 109 | properties=node_data['node']) |
| 110 | |
| 111 | |
| 112 | # READ data about a collection of nodes in the graph |