Skip to content

Commit 6a56efb

Browse files
committed
server: added a common reponse type for graphman graphql api
1 parent 471cff1 commit 6a56efb

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

server/graphman/src/entities/empty_response.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,11 @@ use async_graphql::SimpleObject;
55
#[derive(Clone, Debug, SimpleObject)]
66
pub struct EmptyResponse {
77
pub success: bool,
8-
pub message: Option<String>,
98
}
109

1110
impl EmptyResponse {
1211
/// Returns a successful response.
13-
pub fn new(msg: Option<String>) -> Self {
14-
Self {
15-
success: true,
16-
message: msg,
17-
}
12+
pub fn new() -> Self {
13+
Self { success: true }
1814
}
1915
}

server/graphman/src/entities/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod deployment_version_selector;
99
mod empty_response;
1010
mod execution;
1111
mod execution_id;
12+
mod response;
1213
mod subgraph_health;
1314

1415
pub use self::block_hash::BlockHash;
@@ -22,4 +23,5 @@ pub use self::deployment_version_selector::DeploymentVersionSelector;
2223
pub use self::empty_response::EmptyResponse;
2324
pub use self::execution::Execution;
2425
pub use self::execution_id::ExecutionId;
26+
pub use self::response::Response;
2527
pub use self::subgraph_health::SubgraphHealth;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use async_graphql::SimpleObject;
2+
3+
#[derive(Clone, Debug, SimpleObject)]
4+
pub struct Response {
5+
pub success: bool,
6+
pub message: String,
7+
}
8+
9+
impl Response {
10+
/// Returns a response with success & message.
11+
pub fn new(success: bool, msg: String) -> Self {
12+
Self {
13+
success,
14+
message: msg,
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)