Merge pull request #8323 from tchak/fix-graphql-champs

feat(graphql): add pays champ to API
This commit is contained in:
mfo 2022-12-22 13:51:02 +01:00 committed by GitHub
commit 62813f3d74
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 6 deletions

View file

@ -59,6 +59,7 @@ class API::V2::Schema < GraphQL::Schema
Types::Champs::IntegerNumberChampType,
Types::Champs::LinkedDropDownListChampType,
Types::Champs::MultipleDropDownListChampType,
Types::Champs::PaysChampType,
Types::Champs::PieceJustificativeChampType,
Types::Champs::RegionChampType,
Types::Champs::RepetitionChampType,

View file

@ -454,6 +454,12 @@ class API::V2::StoredQuery
code
}
}
... on PaysChamp {
pays {
name
code
}
}
... on SiretChamp {
etablissement {
...PersonneMoraleFragment

View file

@ -2017,6 +2017,26 @@ type ParcelleCadastrale implements GeoArea {
surfaceParcelle: Float! @deprecated(reason: "Utilisez le champ `surface` à la place.")
}
type Pays {
code: String!
name: String!
}
type PaysChamp implements Champ {
id: ID!
"""
Libellé du champ.
"""
label: String!
pays: Pays
"""
La valeur du champ sous forme texte.
"""
stringValue: String
}
type PersonneMorale implements Demandeur {
address: Address!
adresse: String! @deprecated(reason: "Utilisez le champ `address.label` à la place.")

View file

@ -43,6 +43,12 @@ module Types
else
Types::Champs::TextChampType
end
when ::Champs::PaysChamp
if context.has_fragment?(:PaysChamp)
Types::Champs::PaysChampType
else
Types::Champs::TextChampType
end
when ::Champs::DossierLinkChamp
Types::Champs::DossierLinkChampType
when ::Champs::PieceJustificativeChamp

View file

@ -0,0 +1,16 @@
module Types::Champs
class PaysChampType < Types::BaseObject
implements Types::ChampType
class PaysType < Types::BaseObject
field :name, String, null: false
field :code, String, null: false
end
field :pays, PaysType, null: true
def pays
object if object.external_id.present?
end
end
end

View file

@ -22,15 +22,15 @@
#
class Champs::PaysChamp < Champs::TextChamp
def for_export
[formatted_value, code]
[name, code]
end
def to_s
formatted_value
name
end
def for_tag
formatted_value
name
end
def selected
@ -54,9 +54,7 @@ class Champs::PaysChamp < Champs::TextChamp
external_id || APIGeoService.country_code(value)
end
private
def formatted_value
def name
if external_id
APIGeoService.country_name(external_id)
else