Skip to content

Commit e0d90c2

Browse files
authored
fix(server/http): graphql server compliance issues (#4507)
* fix(server/http): graphql server compliance issues
1 parent 1535e24 commit e0d90c2

File tree

7 files changed

+202
-33
lines changed

7 files changed

+202
-33
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ lcov.info
2828
# Built solidity contracts.
2929
/tests/**/bin
3030
/tests/**/truffle_output
31+
32+
# Docker volumes and debug logs
33+
.postgres
34+
logfile

docker/docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ services:
2828
volumes:
2929
- ./data/ipfs:/data/ipfs
3030
postgres:
31-
image: postgres
31+
image: postgres:14
3232
ports:
3333
- '5432:5432'
3434
command:

graph/src/data/query/result.rs

+2
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,10 @@ impl QueryResults {
190190

191191
pub fn as_http_response<T: From<String>>(&self) -> http::Response<T> {
192192
let status_code = http::StatusCode::OK;
193+
193194
let json =
194195
serde_json::to_string(self).expect("Failed to serialize GraphQL response to JSON");
196+
195197
http::Response::builder()
196198
.status(status_code)
197199
.header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")

server/http/src/server.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use std::net::{Ipv4Addr, SocketAddrV4};
22

3+
use futures::future::Future;
34
use hyper::service::make_service_fn;
45
use hyper::Server;
6+
use thiserror::Error;
57

68
use crate::service::GraphQLService;
7-
use graph::prelude::{GraphQLServer as GraphQLServerTrait, *};
8-
use thiserror::Error;
9+
use graph::prelude::{GraphQLServer as GraphQLServerTrait, GraphQlRunner, *};
910

1011
/// Errors that may occur when starting the server.
1112
#[derive(Debug, Error)]
@@ -66,12 +67,14 @@ where
6667
let graphql_runner = self.graphql_runner.clone();
6768
let node_id = self.node_id.clone();
6869
let new_service = make_service_fn(move |_| {
69-
futures03::future::ok::<_, Error>(GraphQLService::new(
70+
let graphql_service = GraphQLService::new(
7071
logger_for_service.clone(),
7172
graphql_runner.clone(),
7273
ws_port,
7374
node_id.clone(),
74-
))
75+
);
76+
77+
futures03::future::ok::<_, Error>(graphql_service)
7578
});
7679

7780
// Create a task to run the server and handle HTTP requests

0 commit comments

Comments
 (0)