Merge pull request #10082 from tchak/fix-address-city_name

fix(graphql): no crash on address type without city_name
This commit is contained in:
Paul Chavard 2024-03-08 13:40:47 +00:00 committed by GitHub
commit 3febf1bafd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,5 +25,29 @@ module Types
field :region_code, String, "n° de region", null: true
field :geometry, Types::GeoJSON, "coordonnées géographique", null: true
def city_name
if object[:departement_code].present? && object[:city_code].present?
APIGeoService.commune_name(object.fetch(:departement_code), object.fetch(:city_code))
else
object[:city_name]
end
end
def departement_name
if object[:departement_code].present?
APIGeoService.departement_name(object.fetch(:departement_code))
else
object[:departement_name]
end
end
def region_name
if object[:region_code].present?
APIGeoService.region_name(object.fetch(:region_code))
else
object[:region_name]
end
end
end
end