api_testing_core/graphql/
report.rs1use crate::report::{ReportBuilder, ReportHeader};
2
3#[derive(Debug, Clone, PartialEq, Eq)]
4pub struct GraphqlReport {
5 pub report_date: String,
6 pub case_name: String,
7 pub generated_at: String,
8 pub endpoint_note: String,
9 pub result_note: String,
10 pub command_snippet: Option<String>,
11 pub operation: String,
12 pub variables_note: Option<String>,
13 pub variables_json: String,
14 pub response_note: Option<String>,
15 pub response_lang: String,
16 pub response_body: String,
17}
18
19pub fn render_graphql_report_markdown(report: &GraphqlReport) -> String {
20 let header = ReportHeader {
21 report_date: &report.report_date,
22 case_name: &report.case_name,
23 generated_at: &report.generated_at,
24 endpoint_note: &report.endpoint_note,
25 result_note: &report.result_note,
26 command_snippet: report.command_snippet.as_deref(),
27 };
28 let mut builder = ReportBuilder::new(header);
29
30 builder.push_code_section(
31 "GraphQL Operation",
32 "graphql",
33 &report.operation,
34 None,
35 true,
36 );
37 builder.push_code_section(
38 "GraphQL Operation (Variables)",
39 "json",
40 &report.variables_json,
41 report.variables_note.as_deref(),
42 true,
43 );
44 builder.push_code_section(
45 "Response",
46 &report.response_lang,
47 &report.response_body,
48 report.response_note.as_deref(),
49 false,
50 );
51
52 builder.finish()
53}