Skip to content
Merged
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 @@ -15,16 +15,16 @@ class UpdateModuleConfigurations < BaseMutation
required: true,
description: 'The project runtime assignment to update.'

field :namespace_project_runtime_assignment, Types::NamespaceProjectRuntimeAssignmentType,
field :module_configurations, [Types::ModuleConfigurationType],
null: true,
description: 'The updated project runtime assignment.'
description: 'The updated module configurations.'

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

if runtime_assignment.nil?
return {
namespace_project_runtime_assignment: nil,
module_configurations: nil,
errors: [create_error(:runtime_not_assigned, 'Invalid project runtime assignment')],
}
end
Expand All @@ -33,7 +33,7 @@ def resolve(namespace_project_runtime_assignment_id:, module_configurations:)
current_authentication,
runtime_assignment,
module_configurations
).execute.to_mutation_response(success_key: :namespace_project_runtime_assignment)
).execute.to_mutation_response(success_key: :module_configurations)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def execute
}
)

ServiceResponse.success(message: 'Updated module configurations', payload: runtime_assignment)
ServiceResponse.success(message: 'Updated module configurations', payload: db_configurations)
end

return response if response.error?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Updates the saved module configurations for a project runtime assignment.
|------|------|-------------|
| `clientMutationId` | [`String`](../scalar/string.md) | A unique identifier for the client performing the mutation. |
| `errors` | [`[Error!]!`](../object/error.md) | Errors encountered during execution of the mutation. |
| `namespaceProjectRuntimeAssignment` | [`NamespaceProjectRuntimeAssignment`](../object/namespaceprojectruntimeassignment.md) | The updated project runtime assignment. |
| `moduleConfigurations` | [`[ModuleConfiguration!]`](../object/moduleconfiguration.md) | The updated module configurations. |
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@
mutation($input: NamespacesProjectsRuntimeAssignmentsUpdateModuleConfigurationsInput!) {
namespacesProjectsRuntimeAssignmentsUpdateModuleConfigurations(input: $input) {
#{error_query}
namespaceProjectRuntimeAssignment {
moduleConfigurations {
id
compatible
runtime { id }
moduleConfigurations {
nodes {
id
value
definition {
id
identifier
}
}
value
definition {
id
identifier
}
}
}
Expand Down Expand Up @@ -81,15 +74,12 @@

mutate!

response_assignment = graphql_data_at(
response_configurations = graphql_data_at(
:namespaces_projects_runtime_assignments_update_module_configurations,
:namespace_project_runtime_assignment
:module_configurations
)

expect(response_assignment['id']).to eq(runtime_assignment.to_global_id.to_s)
expect(response_assignment['compatible']).to be(true)
expect(response_assignment.dig('runtime', 'id')).to eq(runtime.to_global_id.to_s)
expect(response_assignment.dig('moduleConfigurations', 'nodes')).to contain_exactly(
expect(response_configurations).to contain_exactly(
a_hash_including(
'value' => 'secret',
'definition' => a_hash_including(
Expand All @@ -116,7 +106,7 @@

expect(
graphql_data_at(:namespaces_projects_runtime_assignments_update_module_configurations,
:namespace_project_runtime_assignment)
:module_configurations)
).to be_nil
expect(
graphql_data_at(:namespaces_projects_runtime_assignments_update_module_configurations, :errors, :error_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
end

it { is_expected.to be_success }
it { expect(service_response.payload).to eq(runtime_assignment) }
it { expect(service_response.payload).to match_array(runtime_assignment.module_configurations) }
it { expect { service_response }.to change { ModuleConfiguration.count }.by(2) }

it 'updates the runtime directly after persisting' do
Expand Down