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:
commit
3febf1bafd
1 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue