feat(graphql): expose more dossier informations

This commit is contained in:
Paul Chavard 2022-03-10 18:19:31 +01:00
parent 14342e72f5
commit ec2f2dc78c
5 changed files with 57 additions and 1 deletions

View file

@ -727,6 +727,11 @@ type Dossier {
"""
dateDerniereModification: ISO8601DateTime!
"""
Date dexpiration.
"""
dateExpiration: ISO8601DateTime
"""
Date du dernier passage en construction.
"""
@ -737,6 +742,16 @@ type Dossier {
"""
datePassageEnInstruction: ISO8601DateTime
"""
Date de la suppression par ladministration.
"""
dateSuppressionParAdministration: ISO8601DateTime
"""
Date de la suppression par lusager.
"""
dateSuppressionParUsager: ISO8601DateTime
"""
Date du dernier traitement.
"""
@ -770,6 +785,7 @@ type Dossier {
Létat du dossier.
"""
state: DossierState!
traitements: [Traitement!]!
usager: Profile!
}
@ -1877,6 +1893,14 @@ enum TitreIdentiteGrantType {
piece_justificative
}
type Traitement {
dateTraitement: ISO8601DateTime!
emailAgentTraitant: String
id: ID!
motivation: String
state: DossierState!
}
enum TypeDeChamp {
"""
Adresse
@ -2104,4 +2128,4 @@ type ValidationError {
A description of the error
"""
message: String!
}
}

View file

@ -20,6 +20,10 @@ module Types
field :date_traitement, GraphQL::Types::ISO8601DateTime, "Date du dernier traitement.", null: true, method: :processed_at
field :date_derniere_modification, GraphQL::Types::ISO8601DateTime, "Date de la dernière modification.", null: false, method: :updated_at
field :date_suppression_par_usager, GraphQL::Types::ISO8601DateTime, "Date de la suppression par lusager.", null: true, method: :hidden_by_user_at
field :date_suppression_par_administration, GraphQL::Types::ISO8601DateTime, "Date de la suppression par ladministration.", null: true, method: :hidden_by_administration_at
field :date_expiration, GraphQL::Types::ISO8601DateTime, "Date dexpiration.", null: true
field :archived, Boolean, null: false
field :motivation, String, null: true
@ -51,11 +55,18 @@ module Types
field :annotations, [Types::ChampType], null: false do
argument :id, ID, required: false
end
field :traitements, [Types::TraitementType], null: false
def state
object.state
end
def date_expiration
if !object.en_instruction?
object.expiration_date.presence || object.approximative_expiration_date
end
end
def usager
if object.user_deleted?
{ email: object.user_email_for(:display), id: -1 }
@ -84,6 +95,10 @@ module Types
Loaders::Association.for(object.class, :followers_instructeurs).load(object)
end
def traitements
Loaders::Association.for(object.class, :traitements).load(object)
end
def messages(id: nil)
if id.present?
Loaders::Record

View file

@ -0,0 +1,9 @@
module Types
class TraitementType < Types::BaseObject
global_id_field :id
field :state, Types::DossierType::DossierState, null: false
field :date_traitement, GraphQL::Types::ISO8601DateTime, null: false, method: :processed_at
field :email_agent_traitant, String, null: true, method: :instructeur_email
field :motivation, String, null: true
end
end

View file

@ -74,6 +74,8 @@ class SerializerService
datePassageEnConstruction
datePassageEnInstruction
dateTraitement
dateSuppressionParUsager
dateSuppressionParAdministration
instructeurs {
email
}

View file

@ -14,6 +14,8 @@ RSpec.describe Types::DossierType, type: :graphql do
let(:variables) { { number: dossier.id } }
it { expect(data[:dossier][:attestation]).not_to be_nil }
it { expect(data[:dossier][:traitements]).to eq([{ state: 'accepte' }]) }
it { expect(data[:dossier][:dateExpiration]).not_to be_nil }
context 'when attestation is nil' do
before do
@ -39,6 +41,10 @@ RSpec.describe Types::DossierType, type: :graphql do
attestation {
url
}
traitements {
state
}
dateExpiration
}
}
GRAPHQL