[GraphQL]: informations du service

This commit is contained in:
Paul Chavard 2019-11-29 12:45:58 +01:00
parent da431295c3
commit b5eafdab56
4 changed files with 76 additions and 1 deletions

View file

@ -285,6 +285,7 @@ type Demarche {
Le numero de la démarche.
"""
number: Int!
service: Service!
"""
L'état de la démarche.
@ -935,6 +936,13 @@ type SelectionUtilisateur implements GeoArea {
source: GeoAreaSource!
}
type Service {
id: ID!
nom: String!
organisme: String!
typeOrganisme: TypeOrganisme!
}
type SiretChamp implements Champ {
etablissement: PersonneMorale
id: ID!
@ -1102,6 +1110,43 @@ enum TypeDeChamp {
yes_no
}
enum TypeOrganisme {
"""
Administration centrale
"""
administration_centrale
"""
Association
"""
association
"""
Autre
"""
autre
"""
Collectivité territoriale
"""
collectivite_territoriale
"""
Établissement denseignement
"""
etablissement_enseignement
"""
Opérateur d'État
"""
operateur_d_etat
"""
Service déconcentré de l'État
"""
service_deconcentre_de_l_etat
}
"""
A valid URL, transported as a string
"""

View file

@ -29,6 +29,7 @@ module Types
field :date_fermeture, GraphQL::Types::ISO8601DateTime, "Date de la fermeture.", null: true, method: :closed_at
field :groupe_instructeurs, [Types::GroupeInstructeurType], null: false
field :service, Types::ServiceType, null: false
field :dossiers, Types::DossierType.connection_type, "Liste de tous les dossiers d'une démarche.", null: false do
argument :order, Types::Order, default_value: :asc, required: false, description: "L'ordre des dossiers."
@ -48,6 +49,10 @@ module Types
Loaders::Association.for(object.class, groupe_instructeurs: { procedure: [:administrateurs] }).load(object)
end
def service
Loaders::Record.for(Service).load(object.service_id)
end
def dossiers(updated_since: nil, created_since: nil, state: nil, order:)
dossiers = object.dossiers.state_not_brouillon.for_api_v2

View file

@ -0,0 +1,15 @@
module Types
class ServiceType < Types::BaseObject
class TypeOrganisme < Types::BaseEnum
Service.type_organismes.each do |symbol_name, string_name|
value(string_name, I18n.t(symbol_name, scope: [:type_organisme]), value: symbol_name)
end
end
global_id_field :id
field :nom, String, null: false
field :type_organisme, TypeOrganisme, null: false
field :organisme, String, null: false
end
end

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe API::V2::GraphqlController do
let(:admin) { create(:administrateur) }
let(:token) { admin.renew_api_token }
let(:procedure) { create(:procedure, :published, :for_individual, :with_all_champs, administrateurs: [admin]) }
let(:procedure) { create(:procedure, :published, :for_individual, :with_service, :with_all_champs, administrateurs: [admin]) }
let(:dossier) do
dossier = create(:dossier,
:en_construction,
@ -40,6 +40,11 @@ describe API::V2::GraphqlController do
email
}
}
service {
nom
typeOrganisme
organisme
}
champDescriptors {
id
type
@ -90,6 +95,11 @@ describe API::V2::GraphqlController do
label: "défaut"
}
],
service: {
nom: procedure.service.nom,
typeOrganisme: procedure.service.type_organisme,
organisme: procedure.service.organisme
},
champDescriptors: procedure.types_de_champ.map do |tdc|
{
id: tdc.to_typed_id,