Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow passing custom headers when persisting queries #4066

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

use std::iter::empty;

use async_trait::async_trait;
use persist_query::persist;
use persist_query::PersistError;
Expand Down Expand Up @@ -35,14 +33,16 @@ impl OperationPersister for RemotePersister {
artifact: ArtifactForPersister,
) -> Result<String, PersistError> {
let params = &self.config.params;
let headers = &self.config.headers;

let url = &self.config.url;
if let Some(semaphore) = &self.semaphore {
let permit = (*semaphore).acquire().await.unwrap();
let result = persist(&artifact.text, url, params, empty()).await;
let result = persist(&artifact.text, url, params, headers).await;
drop(permit);
result
} else {
persist(&artifact.text, url, params, empty()).await
persist(&artifact.text, url, params, headers).await
}
}
}
4 changes: 4 additions & 0 deletions compiler/crates/relay-config/src/project_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ pub struct RemotePersistConfig {
#[serde(default)]
pub params: FnvIndexMap<String, String>,

/// Additional headers to send
#[serde(default)]
pub headers: FnvIndexMap<String, String>,

#[serde(
default,
rename = "concurrency",
Expand Down