timegraph_client/
query.rs

1use graphql_client::{GraphQLQuery, QueryBody};
2use serde::{Deserialize, Serialize};
3
4pub const OPERATION_NAME: &str = "CollectData";
5pub const QUERY: &str = r#"
6mutation CollectData(
7    $feed: String!,
8    $timechainBlock: Int!,
9    $targetBlock: Int!,
10    $taskCycle: Int!,
11    $taskId: Int!,
12    $signature: String!,
13    $shardId: Int!
14    $data: [String!]!
15    $eventId: Int
16    ) {
17        collect(
18            feed: $feed,
19            timechainBlock: $timechainBlock,
20            targetBlock: $targetBlock,
21            taskCycle: $taskCycle,
22            taskId: $taskId,
23            signature: $signature,
24            shardId: $shardId,
25            data: $data,
26            eventId: $eventId) { status }
27    }"#;
28
29type Int = i64;
30
31#[derive(Serialize, Debug)]
32pub struct Variables {
33    pub feed: String,
34    #[serde(rename = "taskId")]
35    pub task_id: Int,
36    #[serde(rename = "taskCycle")]
37    pub task_cycle: Int,
38    #[serde(rename = "targetBlock")]
39    pub target_block: Int,
40    #[serde(rename = "timechainBlock")]
41    pub timechain_block: Int,
42    #[serde(rename = "shardId")]
43    pub shard_id: Int,
44    pub signature: String,
45    pub data: Vec<String>,
46}
47
48#[derive(Deserialize, Debug)]
49pub struct ResponseData {
50    pub collect: CollectDataCollect,
51}
52
53#[derive(Deserialize, Debug)]
54pub struct CollectDataCollect {
55    pub status: String,
56}
57
58pub struct CollectData;
59
60impl GraphQLQuery for CollectData {
61    type Variables = Variables;
62    type ResponseData = ResponseData;
63    fn build_query(variables: Self::Variables) -> QueryBody<Self::Variables> {
64        QueryBody {
65            variables,
66            query: QUERY,
67            operation_name: OPERATION_NAME,
68        }
69    }
70}