先從代碼輸入框入手,找到Editor.jsx文件前端
/// vim src/modules/Editor/Editor.jsx <EditorButton data-testid='submitQuery' onClick={() => this.execCurrent()} disabled={this.getEditorValue().length < 1} title='Play' icon={controlsPlay} /> execCurrent () { this.props.onExecute(this.getEditorValue()) this.clearEditor() this.setState({ notifications: [], historyIndex: -1, buffer: null, expanded: false }) } onExecute: cmd => { const action = executeCommand(cmd) ownProps.bus.send(action.type, action) }
追蹤executeCommand函數到commandsDuck.jsvue
/// vim commandsDuck.js // 這個文件定義了不少先後端鏈接的函數 handleCommandEpic() { }
而後是Graph.jsxnode
initGraphView () { if (!this.graphView) { let NeoConstructor = graphView let measureSize = () => { return { width: this.svgElement.offsetWidth, height: this.getVisualAreaHeight() } } this.graph = createGraph(this.props.nodes, this.props.relationships) this.graphView = new NeoConstructor( this.svgElement, measureSize, this.graph, this.props.graphStyle ) this.graphEH = new GraphEventHandler( this.graph, this.graphView, this.props.getNodeNeighbours, this.props.onItemMouseOver, this.props.onItemSelect, this.props.onGraphModelChange ) this.graphEH.bindEventHandlers() this.props.onGraphModelChange(getGraphStats(this.graph)) this.graphView.resize() this.graphView.update() } }
這個文件中出現了createGraph(this.props.nodes, this.props.relationships)
這個重要的語句
追蹤relationships到VisualizationView.jsxvim
populateDataToStateFromProps (props) { const { nodes, relationships } = bolt.extractNodesAndRelationshipsFromRecordsForOldVis( props.result.records )
這個文件中說明了relationships
與nodes
的來源
接着是bolt.js後端
function setupBoltWorker (id, workFn, onLostConnection = () => {}) { const workerPromise = new Promise((resolve, reject) => { const work = boltWorkPool.doWork({ id, payload: workFn, onmessage: msg => { if (msg.data.type === BOLT_CONNECTION_ERROR_MESSAGE) { work.finish() onLostConnection(msg.data.error) return reject(msg.data.error) } if (msg.data.type === CYPHER_ERROR_MESSAGE) { work.finish() reject(msg.data.error) } else if (msg.data.type === CYPHER_RESPONSE_MESSAGE) { work.finish() resolve(addTypesAsField(msg.data.result)) } else if (msg.data.type === POST_CANCEL_TRANSACTION_MESSAGE) { work.finish() } } }) }) return workerPromise }