lib_client_linear/
graphql.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize)]
5pub struct GraphQLRequest {
6 pub query: String,
7 #[serde(skip_serializing_if = "Option::is_none")]
8 pub variables: Option<serde_json::Value>,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub operation_name: Option<String>,
11}
12
13impl GraphQLRequest {
14 pub fn new(query: impl Into<String>) -> Self {
15 Self {
16 query: query.into(),
17 variables: None,
18 operation_name: None,
19 }
20 }
21
22 pub fn with_variables(mut self, variables: serde_json::Value) -> Self {
23 self.variables = Some(variables);
24 self
25 }
26
27 pub fn with_operation_name(mut self, name: impl Into<String>) -> Self {
28 self.operation_name = Some(name.into());
29 self
30 }
31}
32
33#[derive(Debug, Clone, Deserialize)]
35pub struct GraphQLResponse<T> {
36 pub data: Option<T>,
37 pub errors: Option<Vec<GraphQLError>>,
38}
39
40#[derive(Debug, Clone, Deserialize)]
42pub struct GraphQLError {
43 pub message: String,
44 pub locations: Option<Vec<ErrorLocation>>,
45 pub path: Option<Vec<serde_json::Value>>,
46 pub extensions: Option<serde_json::Value>,
47}
48
49#[derive(Debug, Clone, Deserialize)]
50pub struct ErrorLocation {
51 pub line: u32,
52 pub column: u32,
53}