Merge pull request #4358 from tchak/graphql-instructeurs

[GraphQL] Add groupe_instructeurs to demarche
This commit is contained in:
Paul Chavard 2019-09-26 11:57:09 +02:00 committed by GitHub
commit a616ee835c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 4 deletions

View file

@ -102,8 +102,8 @@ type Demarche {
"""
since: ISO8601DateTime
): DossierConnection!
groupeInstructeurs: [GroupeInstructeur!]!
id: ID!
instructeurs: [Profile!]!
"""
Le numero de la démarche.
@ -279,6 +279,15 @@ type GeoJSON {
type: String!
}
"""
Un groupe instructeur
"""
type GroupeInstructeur {
id: ID!
instructeurs: [Profile!]!
label: String!
}
"""
An ISO 8601-encoded datetime
"""

View file

@ -18,7 +18,7 @@ module Types
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
field :archived_at, GraphQL::Types::ISO8601DateTime, null: true
field :instructeurs, [Types::ProfileType], null: false
field :groupe_instructeurs, [Types::GroupeInstructeurType], null: false
field :dossiers, Types::DossierType.connection_type, "Liste de tous les dossiers d'une démarche.", null: false do
argument :ids, [ID], required: false, description: "Filtrer les dossiers par ID."
@ -32,8 +32,8 @@ module Types
object.aasm.current_state
end
def instructeurs
Loaders::Association.for(Procedure, :instructeurs).load(object)
def groupe_instructeurs
Loaders::Association.for(object.class, groupe_instructeurs: { procedure: [:administrateurs] }).load(object)
end
def dossiers(ids: nil, since: nil)

View file

@ -0,0 +1,17 @@
module Types
class GroupeInstructeurType < Types::BaseObject
description "Un groupe instructeur"
global_id_field :id
field :label, String, null: false
field :instructeurs, [Types::ProfileType], null: false
end
def instructeurs
Loaders::Association.for(object.class, :instructeurs).load(object)
end
def self.authorized?(object, context)
authorized_demarche?(object.procedure, context)
end
end

View file

@ -24,6 +24,12 @@ describe API::V2::GraphqlController do
createdAt
updatedAt
archivedAt
groupeInstructeurs {
label
instructeurs {
email
}
}
champDescriptors {
id
type
@ -67,6 +73,7 @@ describe API::V2::GraphqlController do
archivedAt: nil,
createdAt: procedure.created_at.iso8601,
updatedAt: procedure.updated_at.iso8601,
groupeInstructeurs: [{ instructeurs: [], label: "défaut" }],
champDescriptors: procedure.types_de_champ.map do |tdc|
{
id: tdc.to_typed_id,