demarches-normaliennes/app/graphql/mutations/groupe_instructeur_modifier.rb

20 lines
801 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module Mutations
class GroupeInstructeurModifier < Mutations::BaseMutation
description "Modifier un groupe instructeur."
argument :groupe_instructeur_id, ID, "Groupe instructeur ID.", required: true, loads: Types::GroupeInstructeurType
argument :label, String, "Libellé du groupe instructeur.", required: false
argument :closed, Boolean, "Létat du groupe instructeur.", required: false
field :groupe_instructeur, Types::GroupeInstructeurType, null: true
field :errors, [Types::ValidationErrorType], null: true
def resolve(groupe_instructeur:, label: nil, closed: nil)
if groupe_instructeur.update({ label:, closed: }.compact)
{ groupe_instructeur: }
else
{ errors: groupe_instructeur.errors.full_messages }
end
end
end
end