add dossierChangerGroupeInstructeur mutation
This commit is contained in:
parent
13ab3b465e
commit
62f82cc83c
5 changed files with 114 additions and 1 deletions
|
@ -30,6 +30,8 @@ class Api::V2::Schema < GraphQL::Schema
|
|||
Types::PersonnePhysiqueType
|
||||
when Etablissement
|
||||
Types::PersonneMoraleType
|
||||
when GroupeInstructeur
|
||||
Types::GroupeInstructeurType
|
||||
else
|
||||
raise GraphQL::ExecutionError.new("Unexpected object: #{obj}")
|
||||
end
|
||||
|
|
26
app/graphql/mutations/dossier_changer_groupe_instructeur.rb
Normal file
26
app/graphql/mutations/dossier_changer_groupe_instructeur.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
module Mutations
|
||||
class DossierChangerGroupeInstructeur < Mutations::BaseMutation
|
||||
include DossierHelper
|
||||
|
||||
description "Changer le grope instructeur du dossier."
|
||||
|
||||
argument :dossier_id, ID, "Dossier ID", required: true, loads: Types::DossierType
|
||||
argument :groupe_instructeur_id, ID, "Group instructeur a affecter", required: true, loads: Types::GroupeInstructeurType
|
||||
|
||||
field :dossier, Types::DossierType, null: true
|
||||
field :errors, [Types::ValidationErrorType], null: true
|
||||
|
||||
def resolve(dossier:, groupe_instructeur:)
|
||||
if dossier.groupe_instructeur == groupe_instructeur
|
||||
{ errors: ["Le dossier est déjà avec le grope instructeur: '#{groupe_instructeur.label}'"] }
|
||||
else
|
||||
dossier.update!(groupe_instructeur: groupe_instructeur)
|
||||
{ dossier: dossier }
|
||||
end
|
||||
end
|
||||
|
||||
def authorized?(dossier:, groupe_instructeur:)
|
||||
dossier.groupe_instructeur.procedure == groupe_instructeur.procedure
|
||||
end
|
||||
end
|
||||
end
|
|
@ -438,6 +438,38 @@ type DossierAccepterPayload {
|
|||
errors: [ValidationError!]
|
||||
}
|
||||
|
||||
"""
|
||||
Autogenerated input type of DossierChangerGroupeInstructeur
|
||||
"""
|
||||
input DossierChangerGroupeInstructeurInput {
|
||||
"""
|
||||
A unique identifier for the client performing the mutation.
|
||||
"""
|
||||
clientMutationId: String
|
||||
|
||||
"""
|
||||
Dossier ID
|
||||
"""
|
||||
dossierId: ID!
|
||||
|
||||
"""
|
||||
Group instructeur a affecter
|
||||
"""
|
||||
groupeInstructeurId: ID!
|
||||
}
|
||||
|
||||
"""
|
||||
Autogenerated return type of DossierChangerGroupeInstructeur
|
||||
"""
|
||||
type DossierChangerGroupeInstructeurPayload {
|
||||
"""
|
||||
A unique identifier for the client performing the mutation.
|
||||
"""
|
||||
clientMutationId: String
|
||||
dossier: Dossier
|
||||
errors: [ValidationError!]
|
||||
}
|
||||
|
||||
"""
|
||||
Autogenerated input type of DossierClasserSansSuite
|
||||
"""
|
||||
|
@ -790,6 +822,11 @@ type Mutation {
|
|||
"""
|
||||
dossierAccepter(input: DossierAccepterInput!): DossierAccepterPayload
|
||||
|
||||
"""
|
||||
Changer le grope instructeur du dossier.
|
||||
"""
|
||||
dossierChangerGroupeInstructeur(input: DossierChangerGroupeInstructeurInput!): DossierChangerGroupeInstructeurPayload
|
||||
|
||||
"""
|
||||
Classer le dossier sans suite.
|
||||
"""
|
||||
|
@ -1190,4 +1227,4 @@ type ValidationError {
|
|||
A description of the error
|
||||
"""
|
||||
message: String!
|
||||
}
|
||||
}
|
|
@ -7,5 +7,6 @@ module Types
|
|||
field :dossier_classer_sans_suite, mutation: Mutations::DossierClasserSansSuite
|
||||
field :dossier_refuser, mutation: Mutations::DossierRefuser
|
||||
field :dossier_accepter, mutation: Mutations::DossierAccepter
|
||||
field :dossier_changer_groupe_instructeur, mutation: Mutations::DossierChangerGroupeInstructeur
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue