feat(API): cast type de champ EJ in a dedicated graphql type

This commit is contained in:
Martin 2023-12-21 14:22:15 +01:00
parent e52bd9d6bf
commit 989a7ba787
6 changed files with 110 additions and 1 deletions

View file

@ -74,6 +74,7 @@ class API::V2::Schema < GraphQL::Schema
Types::Champs::SiretChampType,
Types::Champs::TextChampType,
Types::Champs::TitreIdentiteChampType,
Types::Champs::EngagementJuridiqueChampType,
Types::GeoAreas::ParcelleCadastraleType,
Types::GeoAreas::SelectionUtilisateurType,
Types::PersonneMoraleType,
@ -118,7 +119,7 @@ class API::V2::Schema < GraphQL::Schema
Types::Champs::Descriptor::TitreIdentiteChampDescriptorType,
Types::Champs::Descriptor::YesNoChampDescriptorType,
Types::Champs::Descriptor::ExpressionReguliereChampDescriptorType,
Types::Champs::Descriptor::EngagementJuridiqueChampDescriptorType
Types::Champs::Descriptor::EngagementJuridiqueChampDescriptorType
def self.unauthorized_object(error)
# Add a top-level error to the response instead of returning nil:

View file

@ -574,6 +574,11 @@ class API::V2::StoredQuery
...RNFFragment
}
}
... on EngagementJuridiqueChamp {
engagementJuridique {
...EngagementJuridiqueFragment
}
}
}
fragment PersonneMoraleFragment on PersonneMorale {
@ -684,6 +689,11 @@ class API::V2::StoredQuery
}
}
fragment EngagementJuridiqueFragment on EngagementJuridique {
montantEngage
montantPaye
}
fragment PageInfoFragment on PageInfo {
hasPreviousPage
hasNextPage

View file

@ -2203,6 +2203,35 @@ type EmailChampDescriptor implements ChampDescriptor {
type: TypeDeChamp! @deprecated(reason: "Utilisez le champ `__typename` à la place.")
}
type EngagementJuridique {
montantEngage: String
montantPaye: String
}
type EngagementJuridiqueChamp implements Champ {
"""
Montant engagé et payé de l'EJ.
"""
engagementJuridique: EngagementJuridique
id: ID!
"""
Libellé du champ.
"""
label: String!
prefilled: Boolean!
"""
La valeur du champ sous forme texte.
"""
stringValue: String
"""
Date de dernière modification du champ.
"""
updatedAt: ISO8601DateTime!
}
type EngagementJuridiqueChampDescriptor implements ChampDescriptor {
"""
Description des champs dun bloc répétable.

View file

@ -77,6 +77,8 @@ module Types
Types::Champs::EpciChampType
when ::Champs::RNFChamp
Types::Champs::RNFChampType
when ::Champs::EngagementJuridiqueChamp
Types::Champs::EngagementJuridiqueChampType
else
Types::Champs::TextChampType
end

View file

@ -0,0 +1,28 @@
module Types::Champs
class EngagementJuridiqueChampType < Types::BaseObject
implements Types::ChampType
class EngagementJuridiqueType < Types::BaseObject
field :montant_engage, String, null: true
field :montant_paye, String, null: true
def numero
object.value
end
def montant_engage
"NotYetImplemented"
end
def montant_paye
"NotYetImplemented"
end
end
field :engagement_juridique, EngagementJuridiqueType, "Montant engagé et payé de l'EJ.", null: true
def engagement_juridique
object if object.value.present?
end
end
end