Skip to content

Commit 418156c

Browse files
committed
add dips graphql
1 parent 5edf6cf commit 418156c

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

service/src/routes/dips.rs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
use async_graphql::{Context, FieldResult, Object, SimpleObject};
2+
3+
#[derive(SimpleObject, Debug)]
4+
struct Agreement {
5+
signature: String,
6+
data: String,
7+
protocol_network: String,
8+
}
9+
10+
#[derive(SimpleObject, Debug)]
11+
struct Price {
12+
price_per_block: String,
13+
chain_id: String,
14+
protocol_network: String,
15+
}
16+
17+
#[derive(Debug)]
18+
pub struct AgreementQuery {}
19+
20+
#[Object]
21+
impl AgreementQuery {
22+
pub async fn get_agreement<'a>(
23+
&self,
24+
ctx: &'a Context<'_>,
25+
signature: String,
26+
) -> FieldResult<Agreement> {
27+
todo!()
28+
}
29+
30+
pub async fn get_price<'a>(
31+
&self,
32+
ctx: &'a Context<'_>,
33+
protocol_network: String,
34+
chain_id: String,
35+
) -> FieldResult<Price> {
36+
todo!()
37+
}
38+
39+
pub async fn get_all_prices<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Price>> {
40+
todo!()
41+
}
42+
}
43+
44+
#[derive(Debug)]
45+
pub struct AgreementMutation {}
46+
47+
#[Object]
48+
impl AgreementMutation {
49+
pub async fn create_agreement<'a>(
50+
&self,
51+
ctx: &'a Context<'_>,
52+
signature: String,
53+
data: String,
54+
) -> FieldResult<Agreement> {
55+
todo!()
56+
}
57+
58+
pub async fn cancel_agreement<'a>(
59+
&self,
60+
ctx: &'a Context<'_>,
61+
signature: String,
62+
) -> FieldResult<Agreement> {
63+
todo!()
64+
}
65+
}

service/src/routes/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
pub mod cost;
5+
pub mod dips;
56
mod status;
67

78
pub use status::status;

service/src/service.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ use std::time::Duration;
66

77
use super::{config::Config, error::SubgraphServiceError, routes};
88
use anyhow::anyhow;
9-
use axum::{async_trait, routing::post, Json, Router};
9+
use async_graphql::{EmptySubscription, Schema};
10+
use async_graphql_axum::GraphQL;
11+
use axum::{
12+
async_trait,
13+
routing::{post, post_service},
14+
Json, Router,
15+
};
1016
use indexer_common::indexer_service::http::{
1117
AttestationOutput, IndexerServiceImpl, IndexerServiceResponse,
1218
};
@@ -173,6 +179,13 @@ pub async fn run() -> anyhow::Result<()> {
173179
.clone(),
174180
});
175181

182+
let schema = Schema::build(
183+
routes::dips::AgreementQuery {},
184+
routes::dips::AgreementMutation {},
185+
EmptySubscription,
186+
)
187+
.finish();
188+
176189
IndexerService::run(IndexerServiceOptions {
177190
release,
178191
config: config.0.clone(),
@@ -182,6 +195,7 @@ pub async fn run() -> anyhow::Result<()> {
182195
extra_routes: Router::new()
183196
.route("/cost", post(routes::cost::cost))
184197
.route("/status", post(routes::status))
198+
.route("/dips", post_service(GraphQL::new(schema)))
185199
.with_state(state),
186200
})
187201
.await

0 commit comments

Comments
 (0)