feat(graphql): expose departement and region
This commit is contained in:
parent
00218fded2
commit
f17690b1d3
8 changed files with 116 additions and 6 deletions
|
@ -54,11 +54,13 @@ class API::V2::Schema < GraphQL::Schema
|
|||
Types::Champs::DateChampType,
|
||||
Types::Champs::DatetimeChampType,
|
||||
Types::Champs::DecimalNumberChampType,
|
||||
Types::Champs::DepartementChampType,
|
||||
Types::Champs::DossierLinkChampType,
|
||||
Types::Champs::IntegerNumberChampType,
|
||||
Types::Champs::LinkedDropDownListChampType,
|
||||
Types::Champs::MultipleDropDownListChampType,
|
||||
Types::Champs::PieceJustificativeChampType,
|
||||
Types::Champs::RegionChampType,
|
||||
Types::Champs::RepetitionChampType,
|
||||
Types::Champs::SiretChampType,
|
||||
Types::Champs::TextChampType,
|
||||
|
|
|
@ -442,6 +442,18 @@ class API::V2::StoredQuery
|
|||
code
|
||||
}
|
||||
}
|
||||
... on DepartementChamp {
|
||||
departement {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
... on RegionChamp {
|
||||
region {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
... on SiretChamp {
|
||||
etablissement {
|
||||
...PersonneMoraleFragment
|
||||
|
|
|
@ -685,6 +685,21 @@ type Departement {
|
|||
name: String!
|
||||
}
|
||||
|
||||
type DepartementChamp implements Champ {
|
||||
departement: Departement
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
"""
|
||||
Represents direct upload credentials
|
||||
"""
|
||||
|
@ -2088,6 +2103,26 @@ type Query {
|
|||
): GroupeInstructeurWithDossiers!
|
||||
}
|
||||
|
||||
type Region {
|
||||
code: String!
|
||||
name: String!
|
||||
}
|
||||
|
||||
type RegionChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
region: Region
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
type RepetitionChamp implements Champ {
|
||||
champs: [Champ!]! @deprecated(reason: "Utilisez le champ `rows` à la place.")
|
||||
id: ID!
|
||||
|
|
|
@ -31,6 +31,18 @@ module Types
|
|||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
when ::Champs::DepartementChamp
|
||||
if context.has_fragment?(:DepartementChamp)
|
||||
Types::Champs::DepartementChampType
|
||||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
when ::Champs::RegionChamp
|
||||
if context.has_fragment?(:RegionChamp)
|
||||
Types::Champs::RegionChampType
|
||||
else
|
||||
Types::Champs::TextChampType
|
||||
end
|
||||
when ::Champs::DossierLinkChamp
|
||||
Types::Champs::DossierLinkChampType
|
||||
when ::Champs::PieceJustificativeChamp
|
||||
|
|
|
@ -7,13 +7,8 @@ module Types::Champs
|
|||
field :code, String, "Le code INSEE", null: false
|
||||
end
|
||||
|
||||
class DepartementType < Types::BaseObject
|
||||
field :name, String, null: false
|
||||
field :code, String, null: false
|
||||
end
|
||||
|
||||
field :commune, CommuneType, null: true
|
||||
field :departement, DepartementType, null: true
|
||||
field :departement, Types::Champs::DepartementChampType::DepartementType, null: true
|
||||
|
||||
def commune
|
||||
if object.code?
|
||||
|
|
16
app/graphql/types/champs/departement_champ_type.rb
Normal file
16
app/graphql/types/champs/departement_champ_type.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Types::Champs
|
||||
class DepartementChampType < Types::BaseObject
|
||||
implements Types::ChampType
|
||||
|
||||
class DepartementType < Types::BaseObject
|
||||
field :name, String, null: false
|
||||
field :code, String, null: false
|
||||
end
|
||||
|
||||
field :departement, DepartementType, null: true
|
||||
|
||||
def departement
|
||||
object if object.external_id.present?
|
||||
end
|
||||
end
|
||||
end
|
16
app/graphql/types/champs/region_champ_type.rb
Normal file
16
app/graphql/types/champs/region_champ_type.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Types::Champs
|
||||
class RegionChampType < Types::BaseObject
|
||||
implements Types::ChampType
|
||||
|
||||
class RegionType < Types::BaseObject
|
||||
field :name, String, null: false
|
||||
field :code, String, null: false
|
||||
end
|
||||
|
||||
field :region, RegionType, null: true
|
||||
|
||||
def region
|
||||
object if object.external_id.present?
|
||||
end
|
||||
end
|
||||
end
|
|
@ -191,6 +191,28 @@ class SerializerService
|
|||
...AddressFragment
|
||||
}
|
||||
}
|
||||
... on CommuneChamp {
|
||||
commune {
|
||||
name
|
||||
code
|
||||
}
|
||||
departement {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
... on DepartementChamp {
|
||||
departement {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
... on RegionChamp {
|
||||
region {
|
||||
name
|
||||
code
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fragment RepetitionChampFragment on RepetitionChamp {
|
||||
|
|
Loading…
Reference in a new issue