# GetKnowledgeGraphQueryHandler

- File ID: file:16f33jo:getknowledgegraphqueryhandler-cs
- Path: NexusReader.Application/Queries/Graph/GetKnowledgeGraphQueryHandler.cs
- Role: handler
- Layer: application

## Purpose

Handles GetKnowledgeGraphQuery by validating input, calling the knowledge service to retrieve graph data, and returning a GraphDataDto wrapped in a FluentResults Result.

## Key Details

Core runtime path: guard for empty input -> call knowledge service -> if service fails propagate failure -> if service returns null graph return empty GraphDataDto; uses FluentResults for result wrapping.

## Symbols

- GetKnowledgeGraphQueryHandler: Handles GetKnowledgeGraphQuery by validating input, calling the knowledge service to retrieve graph data, and returning a GraphDataDto wrapped in a FluentResults Result.
- GetKnowledgeGraphQueryHandler(): Constructor that injects the IKnowledgeService dependency.
- Handle(): Validates the query text, calls IKnowledgeService.GetGraphDataAsync to obtain graph data, and returns appropriate Result<GraphDataDto> (empty, failed, or the graph).

## Dependencies

- No resolved dependencies.

## Calls

- No resolved calls.

## Unresolved References

- dependency-target: NexusReader.Application.Abstractions.Messaging (IQueryHandler)
- dependency-target: NexusReader.Application.Abstractions.Services (IKnowledgeService)
- call-target: unknown
- interaction-target: await _knowledgeService.GetGraphDataAsync(...)

## Coverage

- Symbols: 3
- Executable symbols: 2
- Executable symbols with control flow: 2
- Grounded edges: 3
- Unresolved references: 4
- Control-flow fragments: 2
- Unresolved jumps: 1
- Unsupported constructs: 0
- Control-flow coverage: 100%
- Required diagrams: 2
- Generated diagrams: 3

## Control Flow Fragments

- GetKnowledgeGraphQueryHandler: 3 nodes, 2 edges, 0 jumps, 0 unsupported constructs
- Handle: 26 nodes, 29 edges, 1 jumps, 0 unsupported constructs

## Diagrams

### GetKnowledgeGraphQueryHandler Neighborhood

```mermaid
flowchart LR
    class_p0no6_getknowledgegraphqueryhandler("GetKnowledgeGraphQueryHandler")
    file_16f33jo_getknowledgegraphqueryhandler_cs("GetKnowledgeGraphQueryHandler")
    method_rci0sa_getknowledgegraphqueryhandler[["GetKnowledgeGraphQueryHandler()"]]
    method_tgg1x1_handle[["Handle()"]]
```

### GetKnowledgeGraphQueryHandler Execution Overview

```mermaid
flowchart TD
    class_p0no6_getknowledgegraphqueryhandler("GetKnowledgeGraphQueryHandler")
    method_rci0sa_getknowledgegraphqueryhandler[["GetKnowledgeGraphQueryHandler()"]]
    method_tgg1x1_handle[["Handle()"]]
    unresolved_unresolved_180ldv3_interaction_target{"Unresolved: await _knowledgeService.GetGraphDataAsync(...)"}
    unresolved_unresolved_i84gum_call_target{"Unresolved: GetGraphDataAsync"}
    class_p0no6_getknowledgegraphqueryhandler -->|contains| method_rci0sa_getknowledgegraphqueryhandler
    class_p0no6_getknowledgegraphqueryhandler -->|contains| method_tgg1x1_handle
    class_p0no6_getknowledgegraphqueryhandler -->|unresolved interaction| unresolved_unresolved_180ldv3_interaction_target
    method_tgg1x1_handle -->|unresolved call| unresolved_unresolved_i84gum_call_target
```

### Handle() Control Flow

_Warnings: diagram method_tgg1x1_handle__fragment_diagram exceeds preferred complexity thresholds (26 nodes, 29 edges)._

```mermaid
---
config:
  flowchart:
    defaultRenderer: "elk"
---
flowchart TD
    method_tgg1x1_handle__call_21_GetGraphDataAsync[["GetGraphDataAsync"]]
    method_tgg1x1_handle__action_18_guard_clause_18__condition{"string.IsNullOrWhiteSpace(request.Text)"}
    method_tgg1x1_handle__action_18_guard_clause_18__false("continue")
    method_tgg1x1_handle__action_18_guard_clause_18__merge("merge")
    method_tgg1x1_handle__action_18_guard_clause_18__true("return empty GraphDataDto")
    method_tgg1x1_handle__action_18_handle_branch_18_0__condition{"string.IsNullOrWhiteSpace(request.Text)"}
    method_tgg1x1_handle__action_18_handle_branch_18_0__false("false")
    method_tgg1x1_handle__action_18_handle_branch_18_0__merge("merge")
    method_tgg1x1_handle__action_18_handle_branch_18_0__true("true")
    method_tgg1x1_handle__action_21_handle_await_21_2__await[["Waits for async work"]]
    method_tgg1x1_handle__action_27_branch_27__condition{"result.IsFailed"}
    method_tgg1x1_handle__action_27_branch_27__false("continue")
    method_tgg1x1_handle__action_27_branch_27__merge("merge")
    method_tgg1x1_handle__action_27_branch_27__true("return failure Result<GraphDataDto>")
    method_tgg1x1_handle__action_27_handle_branch_27_3__condition{"result.IsFailed"}
    method_tgg1x1_handle__action_27_handle_branch_27_3__false("false")
    method_tgg1x1_handle__action_27_handle_branch_27_3__merge("merge")
    method_tgg1x1_handle__action_27_handle_branch_27_3__true("true")
    method_tgg1x1_handle__action_30_assignment_30__linear("Extract graph from service result")
    method_tgg1x1_handle__action_32_null_check_32__linear("Return empty DTO if graph is null")
    method_tgg1x1_handle__entry(["Handle entry"])
    method_tgg1x1_handle__action_21_external_call_21__linear("Fetch graph data")
    method_tgg1x1_handle__action_19_handle_return_19_1__return(["Returns result"])
    method_tgg1x1_handle__action_28_handle_return_28_4__return(["Returns result"])
    method_tgg1x1_handle__action_32_handle_return_32_5__return(["Returns result"])
    method_tgg1x1_handle__implicit_return(["return"])
    method_tgg1x1_handle__action_18_guard_clause_18__condition -->|continue| method_tgg1x1_handle__action_18_guard_clause_18__false
    method_tgg1x1_handle__action_18_guard_clause_18__condition -->|return empty GraphDataDto| method_tgg1x1_handle__action_18_guard_clause_18__true
    method_tgg1x1_handle__action_18_guard_clause_18__false -->|next| method_tgg1x1_handle__action_18_guard_clause_18__merge
    method_tgg1x1_handle__action_18_guard_clause_18__merge -->|return| method_tgg1x1_handle__action_19_handle_return_19_1__return
    method_tgg1x1_handle__action_18_guard_clause_18__true -->|next| method_tgg1x1_handle__action_18_guard_clause_18__merge
    method_tgg1x1_handle__action_18_handle_branch_18_0__condition -->|false| method_tgg1x1_handle__action_18_handle_branch_18_0__false
    method_tgg1x1_handle__action_18_handle_branch_18_0__condition -->|true| method_tgg1x1_handle__action_18_handle_branch_18_0__true
    method_tgg1x1_handle__action_18_handle_branch_18_0__false -->|next| method_tgg1x1_handle__action_18_handle_branch_18_0__merge
    method_tgg1x1_handle__action_18_handle_branch_18_0__merge -->|next| method_tgg1x1_handle__action_18_guard_clause_18__condition
    method_tgg1x1_handle__action_18_handle_branch_18_0__true -->|next| method_tgg1x1_handle__action_18_handle_branch_18_0__merge
    method_tgg1x1_handle__action_19_handle_return_19_1__return -->|next| method_tgg1x1_handle__action_21_handle_await_21_2__await
    method_tgg1x1_handle__action_21_external_call_21__linear -->|request.Text, request.TenantId, ebookId: request.EbookId, cancellationToken: cancellationToken| method_tgg1x1_handle__call_21_GetGraphDataAsync
    method_tgg1x1_handle__action_21_handle_await_21_2__await -->|next| method_tgg1x1_handle__action_21_external_call_21__linear
    method_tgg1x1_handle__action_27_branch_27__condition -->|continue| method_tgg1x1_handle__action_27_branch_27__false
    method_tgg1x1_handle__action_27_branch_27__condition -->|return failure Result GraphDataDto>| method_tgg1x1_handle__action_27_branch_27__true
    method_tgg1x1_handle__action_27_branch_27__false -->|next| method_tgg1x1_handle__action_27_branch_27__merge
    method_tgg1x1_handle__action_27_branch_27__merge -->|next| method_tgg1x1_handle__action_27_handle_branch_27_3__condition
    method_tgg1x1_handle__action_27_branch_27__true -->|next| method_tgg1x1_handle__action_27_branch_27__merge
    method_tgg1x1_handle__action_27_handle_branch_27_3__condition -->|false| method_tgg1x1_handle__action_27_handle_branch_27_3__false
    method_tgg1x1_handle__action_27_handle_branch_27_3__condition -->|true| method_tgg1x1_handle__action_27_handle_branch_27_3__true
    method_tgg1x1_handle__action_27_handle_branch_27_3__false -->|next| method_tgg1x1_handle__action_27_handle_branch_27_3__merge
    method_tgg1x1_handle__action_27_handle_branch_27_3__merge -->|return| method_tgg1x1_handle__action_28_handle_return_28_4__return
    method_tgg1x1_handle__action_27_handle_branch_27_3__true -->|next| method_tgg1x1_handle__action_27_handle_branch_27_3__merge
    method_tgg1x1_handle__action_28_handle_return_28_4__return -->|next| method_tgg1x1_handle__action_30_assignment_30__linear
    method_tgg1x1_handle__action_30_assignment_30__linear -->|return| method_tgg1x1_handle__action_32_handle_return_32_5__return
    method_tgg1x1_handle__action_32_handle_return_32_5__return -->|next| method_tgg1x1_handle__action_32_null_check_32__linear
    method_tgg1x1_handle__action_32_null_check_32__linear -->|return| method_tgg1x1_handle__implicit_return
    method_tgg1x1_handle__call_21_GetGraphDataAsync -->|next| method_tgg1x1_handle__action_27_branch_27__condition
    method_tgg1x1_handle__entry -->|next| method_tgg1x1_handle__action_18_handle_branch_18_0__condition
```

## Diagram Validation

- Status: warn
- Warning: Control-flow extraction left 1 unresolved jumps.
- Warning: control-flow: diagram method_tgg1x1_handle__fragment_diagram exceeds preferred complexity thresholds (26 nodes, 29 edges).
