Skip to content

Commit 5e750ce

Browse files
Merge pull request #5 from graphops/chris/x-gateway-id
feat: add support for x-gateway-id
2 parents 40227e6 + bb3dbd4 commit 5e750ce

File tree

6 files changed

+348
-173
lines changed

6 files changed

+348
-173
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ axum = "0.8.4"
2424
tokio-util = { version = "0.7.15" }
2525
http = "1.3.1"
2626
tracing = "0.1"
27+
once_cell = "1.20"

src/constants.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
// SPDX-License-Identifier: Apache-2.0
2-
pub const GATEWAY_URL: &str = "https://gateway.thegraph.com/api";
2+
use once_cell::sync::Lazy;
3+
use std::collections::HashMap;
4+
35
pub const GRAPH_NETWORK_SUBGRAPH_ARBITRUM: &str = "QmdKXcBUHR3UyURqVRQHu1oV6VUkBrhi2vNvMx3bNDnUCc";
46
pub const GATEWAY_QOS_ORACLE: &str = "QmZmb6z87QmqBLmkMhaqWy7h2GLF1ey8Qj7YSRuqSGMjeH";
57

8+
// Gateway ID to URL mapping
9+
pub static GATEWAY_REGISTRY: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
10+
let mut m = HashMap::new();
11+
m.insert("edgeandnode", "https://gateway.thegraph.com/api");
12+
m.insert("graphops", "https://graph-gateway.graphops.xyz/api");
13+
m
14+
});
15+
16+
// Default gateway ID
17+
pub const DEFAULT_GATEWAY_ID: &str = "edgeandnode";
18+
619
pub const SUBGRAPH_SERVER_INSTRUCTIONS: &str = "**Interacting with The Graph Subgraphs**
720
**IMPORTANT: ALWAYS verify query volumes using `get_deployment_30day_query_counts` for any potential subgraph candidate *before* selecting or querying it. This step is NON-OPTIONAL. Failure to do so may result in using outdated or irrelevant data.**
821
**Follow this sequence strictly:**

src/error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@ pub enum SubgraphError {
1313
JsonError(#[from] serde_json::Error),
1414
#[error("Internal processing error: {0}")]
1515
InternalProcessingError(String),
16+
#[error("{0}")]
17+
InvalidGatewayId(String),
1618
}

0 commit comments

Comments
 (0)