feat(graphql): add postalCode to champ commune

This commit is contained in:
Paul Chavard 2023-03-21 14:45:48 +01:00
parent dc605015b3
commit 666db74b09
2 changed files with 13 additions and 13 deletions

View file

@ -404,7 +404,16 @@ type Commune {
Le code INSEE Le code INSEE
""" """
code: String! code: String!
"""
Le nom de la commune
"""
name: String! name: String!
"""
Le code postal
"""
postalCode: String
} }
type CommuneChamp implements Champ { type CommuneChamp implements Champ {

View file

@ -3,29 +3,20 @@ module Types::Champs
implements Types::ChampType implements Types::ChampType
class CommuneType < Types::BaseObject class CommuneType < Types::BaseObject
field :name, String, null: false field :name, String, "Le nom de la commune", null: false
field :code, String, "Le code INSEE", null: false field :code, String, "Le code INSEE", null: false
field :postal_code, String, "Le code postal", null: true, method: :code_postal
end end
field :commune, CommuneType, null: true field :commune, CommuneType, null: true
field :departement, Types::Champs::DepartementChampType::DepartementType, null: true field :departement, Types::Champs::DepartementChampType::DepartementType, null: true
def commune def commune
if object.code? object if object.code?
{
name: object.to_s,
code: object.code
}
end
end end
def departement def departement
if object.departement? object.departement if object.departement?
{
name: object.name_departement,
code: object.code_departement
}
end
end end
end end
end end