From 666db74b090e6fd1257fdd733089d01356bb1a4f Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Tue, 21 Mar 2023 14:45:48 +0100 Subject: [PATCH] feat(graphql): add postalCode to champ commune --- app/graphql/schema.graphql | 9 +++++++++ app/graphql/types/champs/commune_champ_type.rb | 17 ++++------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/graphql/schema.graphql b/app/graphql/schema.graphql index 4ddc0306f..d11659d5d 100644 --- a/app/graphql/schema.graphql +++ b/app/graphql/schema.graphql @@ -404,7 +404,16 @@ type Commune { Le code INSEE """ code: String! + + """ + Le nom de la commune + """ name: String! + + """ + Le code postal + """ + postalCode: String } type CommuneChamp implements Champ { diff --git a/app/graphql/types/champs/commune_champ_type.rb b/app/graphql/types/champs/commune_champ_type.rb index 6502f0606..99758ba9f 100644 --- a/app/graphql/types/champs/commune_champ_type.rb +++ b/app/graphql/types/champs/commune_champ_type.rb @@ -3,29 +3,20 @@ module Types::Champs implements Types::ChampType 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 :postal_code, String, "Le code postal", null: true, method: :code_postal end field :commune, CommuneType, null: true field :departement, Types::Champs::DepartementChampType::DepartementType, null: true def commune - if object.code? - { - name: object.to_s, - code: object.code - } - end + object if object.code? end def departement - if object.departement? - { - name: object.name_departement, - code: object.code_departement - } - end + object.departement if object.departement? end end end