Skip to content

Commit 927d465

Browse files
authored
Merge pull request #1004 from code0-tech/#1003-correct-module-mutations
correct mutation connection
2 parents 0257fed + a65a6d5 commit 927d465

5 files changed

Lines changed: 16 additions & 26 deletions

File tree

app/graphql/mutations/namespaces/projects/runtime_assignments/update_module_configurations.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ class UpdateModuleConfigurations < BaseMutation
1515
required: true,
1616
description: 'The project runtime assignment to update.'
1717

18-
field :namespace_project_runtime_assignment, Types::NamespaceProjectRuntimeAssignmentType,
18+
field :module_configurations, [Types::ModuleConfigurationType],
1919
null: true,
20-
description: 'The updated project runtime assignment.'
20+
description: 'The updated module configurations.'
2121

2222
def resolve(namespace_project_runtime_assignment_id:, module_configurations:)
2323
runtime_assignment = SagittariusSchema.object_from_id(namespace_project_runtime_assignment_id)
2424

2525
if runtime_assignment.nil?
2626
return {
27-
namespace_project_runtime_assignment: nil,
27+
module_configurations: nil,
2828
errors: [create_error(:runtime_not_assigned, 'Invalid project runtime assignment')],
2929
}
3030
end
@@ -33,7 +33,7 @@ def resolve(namespace_project_runtime_assignment_id:, module_configurations:)
3333
current_authentication,
3434
runtime_assignment,
3535
module_configurations
36-
).execute.to_mutation_response(success_key: :namespace_project_runtime_assignment)
36+
).execute.to_mutation_response(success_key: :module_configurations)
3737
end
3838
end
3939
end

app/services/namespaces/projects/runtime_assignments/update_module_configurations_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def execute
4242
}
4343
)
4444

45-
ServiceResponse.success(message: 'Updated module configurations', payload: runtime_assignment)
45+
ServiceResponse.success(message: 'Updated module configurations', payload: db_configurations)
4646
end
4747

4848
return response if response.error?

docs/graphql/mutation/namespacesprojectsruntimeassignmentsupdatemoduleconfigurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ Updates the saved module configurations for a project runtime assignment.
1818
|------|------|-------------|
1919
| `clientMutationId` | [`String`](../scalar/string.md) | A unique identifier for the client performing the mutation. |
2020
| `errors` | [`[Error!]!`](../object/error.md) | Errors encountered during execution of the mutation. |
21-
| `namespaceProjectRuntimeAssignment` | [`NamespaceProjectRuntimeAssignment`](../object/namespaceprojectruntimeassignment.md) | The updated project runtime assignment. |
21+
| `moduleConfigurations` | [`[ModuleConfiguration!]`](../object/moduleconfiguration.md) | The updated module configurations. |

spec/requests/graphql/mutation/namespace/projects/runtime_assignments/update_module_configurations_mutation_spec.rb

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,12 @@
1212
mutation($input: NamespacesProjectsRuntimeAssignmentsUpdateModuleConfigurationsInput!) {
1313
namespacesProjectsRuntimeAssignmentsUpdateModuleConfigurations(input: $input) {
1414
#{error_query}
15-
namespaceProjectRuntimeAssignment {
15+
moduleConfigurations {
1616
id
17-
compatible
18-
runtime { id }
19-
moduleConfigurations {
20-
nodes {
21-
id
22-
value
23-
definition {
24-
id
25-
identifier
26-
}
27-
}
17+
value
18+
definition {
19+
id
20+
identifier
2821
}
2922
}
3023
}
@@ -81,15 +74,12 @@
8174

8275
mutate!
8376

84-
response_assignment = graphql_data_at(
77+
response_configurations = graphql_data_at(
8578
:namespaces_projects_runtime_assignments_update_module_configurations,
86-
:namespace_project_runtime_assignment
79+
:module_configurations
8780
)
8881

89-
expect(response_assignment['id']).to eq(runtime_assignment.to_global_id.to_s)
90-
expect(response_assignment['compatible']).to be(true)
91-
expect(response_assignment.dig('runtime', 'id')).to eq(runtime.to_global_id.to_s)
92-
expect(response_assignment.dig('moduleConfigurations', 'nodes')).to contain_exactly(
82+
expect(response_configurations).to contain_exactly(
9383
a_hash_including(
9484
'value' => 'secret',
9585
'definition' => a_hash_including(
@@ -116,7 +106,7 @@
116106

117107
expect(
118108
graphql_data_at(:namespaces_projects_runtime_assignments_update_module_configurations,
119-
:namespace_project_runtime_assignment)
109+
:module_configurations)
120110
).to be_nil
121111
expect(
122112
graphql_data_at(:namespaces_projects_runtime_assignments_update_module_configurations, :errors, :error_code)

spec/services/namespaces/projects/runtime_assignments/update_module_configurations_service_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
end
5555

5656
it { is_expected.to be_success }
57-
it { expect(service_response.payload).to eq(runtime_assignment) }
57+
it { expect(service_response.payload).to match_array(runtime_assignment.module_configurations) }
5858
it { expect { service_response }.to change { ModuleConfiguration.count }.by(2) }
5959

6060
it 'updates the runtime directly after persisting' do

0 commit comments

Comments
 (0)