Skip to content

Commit 7b05e19

Browse files
authored
Use environmentPatchCommit in environment edit (#780)
* Use environmentPatchCommit in environment edit * Fix formatting
1 parent 500b29d commit 7b05e19

File tree

3 files changed

+18
-30
lines changed

3 files changed

+18
-30
lines changed

src/commands/environment/edit.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,6 @@ pub async fn edit_environment(args: Args) -> Result<()> {
6161
return Ok(());
6262
}
6363

64-
// Stage changes with merge=true to combine with any existing staged changes
65-
let stage_vars = mutations::environment_stage_changes::Variables {
66-
environment_id: environment_id.clone(),
67-
input: env_config,
68-
merge: Some(true),
69-
};
70-
71-
post_graphql::<mutations::EnvironmentStageChanges, _>(
72-
&client,
73-
configs.get_backboard(),
74-
stage_vars,
75-
)
76-
.await?;
77-
7864
// Determine whether to stage only or apply now
7965
// --stage flag means stage only, --message flag implies apply now
8066
let should_stage_only = if args.stage {
@@ -90,6 +76,20 @@ pub async fn edit_environment(args: Args) -> Result<()> {
9076
};
9177

9278
if should_stage_only {
79+
// Stage only: use environmentStageChanges with merge=true
80+
let stage_vars = mutations::environment_stage_changes::Variables {
81+
environment_id: environment_id.clone(),
82+
input: env_config,
83+
merge: Some(true),
84+
};
85+
86+
post_graphql::<mutations::EnvironmentStageChanges, _>(
87+
&client,
88+
configs.get_backboard(),
89+
stage_vars,
90+
)
91+
.await?;
92+
9393
if json {
9494
println!(
9595
"{}",
@@ -116,14 +116,14 @@ pub async fn edit_environment(args: Args) -> Result<()> {
116116
.clone()
117117
.inspect(|msg| fake_select("Commit message", msg));
118118

119-
// Commit the staged changes
120-
let commit_vars = mutations::environment_patch_commit_staged::Variables {
119+
// Commit directly with patch (single mutation instead of stage + commit)
120+
let commit_vars = mutations::environment_patch_commit::Variables {
121121
environment_id: environment_id.clone(),
122+
patch: env_config,
122123
commit_message: commit_message.clone(),
123-
skip_deploys: None,
124124
};
125125

126-
post_graphql::<mutations::EnvironmentPatchCommitStaged, _>(
126+
post_graphql::<mutations::EnvironmentPatchCommit, _>(
127127
&client,
128128
configs.get_backboard(),
129129
commit_vars,

src/gql/mutations/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,6 @@ pub struct EnvironmentPatchCommit;
253253
)]
254254
pub struct EnvironmentStageChanges;
255255

256-
#[derive(GraphQLQuery)]
257-
#[graphql(
258-
schema_path = "src/gql/schema.json",
259-
query_path = "src/gql/mutations/strings/EnvironmentPatchCommitStaged.graphql",
260-
response_derives = "Debug, Serialize, Clone",
261-
skip_serializing_none
262-
)]
263-
pub struct EnvironmentPatchCommitStaged;
264-
265256
impl std::fmt::Display for custom_domain_create::DNSRecordType {
266257
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
267258
match self {

src/gql/mutations/strings/EnvironmentPatchCommitStaged.graphql

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)