Skip to content

Commit 08c16f8

Browse files
committed
fix(apollo-router-fork): use correct router version instead of commit
env var
1 parent c201e2d commit 08c16f8

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

.changeset/brown-ghosts-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive-apollo-router-plugin': patch
3+
---
4+
5+
Use the correct plugin version in the User-Agent header used for Console requests

packages/libraries/router/src/agent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::consts::PLUGIN_VERSION;
2+
13
use super::graphql::OperationProcessor;
24
use graphql_parser::schema::{parse_schema, Document};
35
use reqwest::Client;
@@ -10,8 +12,6 @@ use std::{
1012
use thiserror::Error;
1113
use tokio::sync::Mutex as AsyncMutex;
1214

13-
static COMMIT: Option<&'static str> = option_env!("GITHUB_SHA");
14-
1515
#[derive(Serialize, Debug)]
1616
pub struct Report {
1717
size: usize,
@@ -299,7 +299,7 @@ impl UsageAgent {
299299
)
300300
.header(
301301
reqwest::header::USER_AGENT,
302-
format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")),
302+
format!("hive-apollo-router/{}", PLUGIN_VERSION),
303303
)
304304
.json(&report)
305305
.send()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub const PLUGIN_VERSION: &str = env!("CARGO_PKG_VERSION");

packages/libraries/router/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mod agent;
2+
pub mod consts;
23
mod graphql;
34
pub mod persisted_documents;
45
pub mod registry;

packages/libraries/router/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Specify the modules our binary should include -- https://twitter.com/YassinEldeeb7/status/1468680104243077128
22
mod agent;
3+
mod consts;
34
mod graphql;
45
mod persisted_documents;
56
mod registry;

packages/libraries/router/src/registry.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::consts::PLUGIN_VERSION;
12
use crate::registry_logger::Logger;
23
use anyhow::{anyhow, Result};
34
use sha2::Digest;
@@ -24,8 +25,6 @@ pub struct HiveRegistryConfig {
2425
schema_file_path: Option<String>,
2526
}
2627

27-
static COMMIT: Option<&'static str> = option_env!("GITHUB_SHA");
28-
2928
impl HiveRegistry {
3029
#[allow(clippy::new_ret_no_self)]
3130
pub fn new(user_config: Option<HiveRegistryConfig>) -> Result<()> {
@@ -171,7 +170,7 @@ impl HiveRegistry {
171170
headers.insert(
172171
reqwest::header::USER_AGENT,
173172
reqwest::header::HeaderValue::from_str(
174-
format!("hive-apollo-router/{}", COMMIT.unwrap_or("local")).as_str(),
173+
format!("hive-apollo-router/{}", PLUGIN_VERSION).as_str(),
175174
)
176175
.unwrap(),
177176
);

0 commit comments

Comments
 (0)