Skip to content

Commit

Permalink
Make subgraph URL's configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
narcis authored and narcis96 committed Dec 6, 2023
1 parent 02bfbbf commit e759151
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/shared/src/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ pub struct SubgraphClient {
}

lazy_static! {
pub static ref DEFAULT_GRAPH_API_BASE_URL: Url =
Url::parse("https://api.thegraph.com/subgraphs/name/")
.expect("invalid default Graph API base URL");
pub static ref DEFAULT_GRAPH_API_BASE_URL: String =
String::from("https://api.thegraph.com/subgraphs/name/");
}

pub trait ContainsId {
Expand All @@ -37,7 +36,11 @@ pub struct Data<T> {
impl SubgraphClient {
/// Creates a new subgraph client from the specified organization and name.
pub fn new(org: impl AsRef<str>, name: impl AsRef<str>, client: Client) -> Result<Self> {
Self::with_base_url(DEFAULT_GRAPH_API_BASE_URL.clone(), org, name, client)
let graph_api_base =
std::env::var("GRAPH_API_BASE_URL").unwrap_or(DEFAULT_GRAPH_API_BASE_URL.clone());
let graph_api_base_url =
Url::parse(&graph_api_base).expect("invalid default Graph API base URL");
Self::with_base_url(graph_api_base_url.clone(), org, name, client)
}

/// Creates a new subgraph client with the specified base URL.
Expand Down

0 comments on commit e759151

Please sign in to comment.