Merge pull request #4496 from tchak/graphql-dossier-number
[GraphQL]: fix some types and add some doc
This commit is contained in:
commit
ad1e3c94a9
10 changed files with 236 additions and 29 deletions
|
@ -10,27 +10,66 @@ type Avis {
|
|||
type CarteChamp implements Champ {
|
||||
geoAreas: [GeoArea!]!
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
interface Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
type ChampDescriptor {
|
||||
"""
|
||||
Description du champ.
|
||||
"""
|
||||
description: String
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
Est-ce que le champ est obligatoire ?
|
||||
"""
|
||||
required: Boolean!
|
||||
|
||||
"""
|
||||
Type de la valeur du champ.
|
||||
"""
|
||||
type: TypeDeChamp!
|
||||
}
|
||||
|
||||
type CheckboxChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
value: Boolean!
|
||||
}
|
||||
|
@ -88,14 +127,30 @@ type CreateDirectUploadPayload {
|
|||
|
||||
type DateChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
value: ISO8601DateTime
|
||||
}
|
||||
|
||||
type DecimalNumberChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
value: Float
|
||||
}
|
||||
|
@ -164,7 +219,11 @@ type Demarche {
|
|||
"""
|
||||
Le numero de la démarche.
|
||||
"""
|
||||
number: ID!
|
||||
number: Int!
|
||||
|
||||
"""
|
||||
L'état de la démarche.
|
||||
"""
|
||||
state: DemarcheState!
|
||||
title: String!
|
||||
updatedAt: ISO8601DateTime!
|
||||
|
@ -244,7 +303,7 @@ type Dossier {
|
|||
"""
|
||||
Le numero du dossier.
|
||||
"""
|
||||
number: ID!
|
||||
number: Int!
|
||||
|
||||
"""
|
||||
L'état du dossier.
|
||||
|
@ -296,7 +355,15 @@ type DossierEdge {
|
|||
type DossierLinkChamp implements Champ {
|
||||
dossier: Dossier
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
|
@ -335,22 +402,17 @@ interface GeoArea {
|
|||
|
||||
enum GeoAreaSource {
|
||||
"""
|
||||
translation missing: fr.activerecord.attributes.geo_area.source.cadastre
|
||||
Parcelle cadastrale
|
||||
"""
|
||||
cadastre
|
||||
|
||||
"""
|
||||
translation missing: fr.activerecord.attributes.geo_area.source.parcelle_agricole
|
||||
"""
|
||||
parcelle_agricole
|
||||
|
||||
"""
|
||||
translation missing: fr.activerecord.attributes.geo_area.source.quartier_prioritaire
|
||||
Quartier prioritaire
|
||||
"""
|
||||
quartier_prioritaire
|
||||
|
||||
"""
|
||||
translation missing: fr.activerecord.attributes.geo_area.source.selection_utilisateur
|
||||
Sélection utilisateur
|
||||
"""
|
||||
selection_utilisateur
|
||||
}
|
||||
|
@ -376,16 +438,32 @@ scalar ISO8601DateTime
|
|||
|
||||
type IntegerNumberChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
value: Int
|
||||
}
|
||||
|
||||
type LinkedDropDownListChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
primaryValue: String
|
||||
secondaryValue: String
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
|
@ -399,7 +477,15 @@ type Message {
|
|||
|
||||
type MultipleDropDownListChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
values: [String!]!
|
||||
}
|
||||
|
@ -480,7 +566,15 @@ type PersonneMorale {
|
|||
|
||||
type PieceJustificativeChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
url: URL
|
||||
}
|
||||
|
@ -507,7 +601,7 @@ type Query {
|
|||
"""
|
||||
Numéro de la démarche.
|
||||
"""
|
||||
number: ID!
|
||||
number: Int!
|
||||
): Demarche!
|
||||
|
||||
"""
|
||||
|
@ -517,14 +611,22 @@ type Query {
|
|||
"""
|
||||
Numéro du dossier.
|
||||
"""
|
||||
number: ID!
|
||||
number: Int!
|
||||
): Dossier!
|
||||
}
|
||||
|
||||
type RepetitionChamp implements Champ {
|
||||
champs: [Champ!]!
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
|
@ -537,13 +639,29 @@ type SelectionUtilisateur implements GeoArea {
|
|||
type SiretChamp implements Champ {
|
||||
etablissement: PersonneMorale
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
}
|
||||
|
||||
type TextChamp implements Champ {
|
||||
id: ID!
|
||||
|
||||
"""
|
||||
Libellé du champ.
|
||||
"""
|
||||
label: String!
|
||||
|
||||
"""
|
||||
La valeur du champ sous forme texte.
|
||||
"""
|
||||
stringValue: String
|
||||
value: String
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ module Types
|
|||
end
|
||||
|
||||
global_id_field :id
|
||||
field :type, TypeDeChampType, null: false, method: :type_champ
|
||||
field :label, String, null: false, method: :libelle
|
||||
field :description, String, null: true
|
||||
field :required, Boolean, null: false, method: :mandatory?
|
||||
field :type, TypeDeChampType, "Type de la valeur du champ.", null: false, method: :type_champ
|
||||
field :label, String, "Libellé du champ.", null: false, method: :libelle
|
||||
field :description, String, "Description du champ.", null: true
|
||||
field :required, Boolean, "Est-ce que le champ est obligatoire ?", null: false, method: :mandatory?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,8 @@ module Types
|
|||
include Types::BaseInterface
|
||||
|
||||
global_id_field :id
|
||||
field :label, String, null: false, method: :libelle
|
||||
field :string_value, String, null: true, method: :for_api_v2
|
||||
field :label, String, "Libellé du champ.", null: false, method: :libelle
|
||||
field :string_value, String, "La valeur du champ sous forme texte.", null: true, method: :for_api_v2
|
||||
|
||||
definition_methods do
|
||||
def resolve_type(object, context)
|
||||
|
|
|
@ -9,10 +9,10 @@ module Types
|
|||
description "Une demarche"
|
||||
|
||||
global_id_field :id
|
||||
field :number, ID, "Le numero de la démarche.", null: false, method: :id
|
||||
field :number, Int, "Le numero de la démarche.", null: false, method: :id
|
||||
field :title, String, null: false, method: :libelle
|
||||
field :description, String, "Déscription de la démarche.", null: false
|
||||
field :state, DemarcheState, null: false
|
||||
field :state, DemarcheState, "L'état de la démarche.", null: false
|
||||
|
||||
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
||||
|
|
|
@ -9,7 +9,7 @@ module Types
|
|||
description "Un dossier"
|
||||
|
||||
global_id_field :id
|
||||
field :number, ID, "Le numero du dossier.", null: false, method: :id
|
||||
field :number, Int, "Le numero du dossier.", null: false, method: :id
|
||||
field :state, DossierState, "L'état du dossier.", null: false
|
||||
field :updated_at, GraphQL::Types::ISO8601DateTime, "Date de dernière mise à jour.", null: false
|
||||
|
||||
|
|
|
@ -4,9 +4,11 @@ module Types
|
|||
|
||||
class GeoAreaSource < Types::BaseEnum
|
||||
GeoArea.sources.each do |symbol_name, string_name|
|
||||
value(string_name,
|
||||
I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]),
|
||||
value: symbol_name)
|
||||
if string_name != "parcelle_agricole"
|
||||
value(string_name,
|
||||
I18n.t(symbol_name, scope: [:activerecord, :attributes, :geo_area, :source]),
|
||||
value: symbol_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
module Types
|
||||
class QueryType < Types::BaseObject
|
||||
field :demarche, DemarcheType, null: false, description: "Informations concernant une démarche." do
|
||||
argument :number, ID, "Numéro de la démarche.", required: true
|
||||
argument :number, Int, "Numéro de la démarche.", required: true
|
||||
end
|
||||
|
||||
field :dossier, DossierType, null: false, description: "Informations sur un dossier d'une démarche." do
|
||||
argument :number, ID, "Numéro du dossier.", required: true
|
||||
argument :number, Int, "Numéro du dossier.", required: true
|
||||
end
|
||||
|
||||
def demarche(number:)
|
||||
|
|
79
config/initializers/graphiql.rb
Normal file
79
config/initializers/graphiql.rb
Normal file
|
@ -0,0 +1,79 @@
|
|||
DEFAULT_QUERY = "# La documentation officielle de la spécification (Anglais) : https://graphql.org/
|
||||
# Une introduction aux concepts et raisons d'être de GraphQL (Français) : https://blog.octo.com/graphql-et-pourquoi-faire/
|
||||
# Le schema GraphQL de demarches-simplifiees.fr : https://demarches-simplifiees-graphql.netlify.com
|
||||
# Le endpoint GraphQL de demarches-simplifiees.fr : https://demarches-simplifiees.fr/api/v2/graphql
|
||||
|
||||
query getDemarche($demarcheNumber: Int!) {
|
||||
demarche(number: $demarcheNumber) {
|
||||
id
|
||||
number
|
||||
title
|
||||
champDescriptors {
|
||||
id
|
||||
type
|
||||
label
|
||||
}
|
||||
dossiers(first: 3) {
|
||||
nodes {
|
||||
id
|
||||
number
|
||||
datePassageEnConstruction
|
||||
datePassageEnInstruction
|
||||
dateTraitement
|
||||
usager {
|
||||
email
|
||||
}
|
||||
champs {
|
||||
id
|
||||
label
|
||||
... on TextChamp {
|
||||
value
|
||||
}
|
||||
... on DecimalNumberChamp {
|
||||
value
|
||||
}
|
||||
... on IntegerNumberChamp {
|
||||
value
|
||||
}
|
||||
... on CheckboxChamp {
|
||||
value
|
||||
}
|
||||
... on DateChamp {
|
||||
value
|
||||
}
|
||||
... on DossierLinkChamp {
|
||||
dossier {
|
||||
id
|
||||
}
|
||||
}
|
||||
... on MultipleDropDownListChamp {
|
||||
values
|
||||
}
|
||||
... on LinkedDropDownListChamp {
|
||||
primaryValue
|
||||
secondaryValue
|
||||
}
|
||||
... on PieceJustificativeChamp {
|
||||
url
|
||||
}
|
||||
... on CarteChamp {
|
||||
geoAreas {
|
||||
source
|
||||
geometry {
|
||||
type
|
||||
coordinates
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
hasNextPage
|
||||
endCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}"
|
||||
|
||||
GraphiQL::Rails.config.initial_query = DEFAULT_QUERY
|
||||
GraphiQL::Rails.config.title = 'demarches-simplifiees.fr'
|
8
config/locales/models/geo_area/fr.yml
Normal file
8
config/locales/models/geo_area/fr.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
fr:
|
||||
activerecord:
|
||||
attributes:
|
||||
geo_area:
|
||||
source:
|
||||
cadastre: Parcelle cadastrale
|
||||
quartier_prioritaire: Quartier prioritaire
|
||||
selection_utilisateur: Sélection utilisateur
|
|
@ -76,7 +76,7 @@ describe API::V2::GraphqlController do
|
|||
expect(gql_errors).to eq(nil)
|
||||
expect(gql_data).to eq(demarche: {
|
||||
id: procedure.to_typed_id,
|
||||
number: procedure.id.to_s,
|
||||
number: procedure.id,
|
||||
title: procedure.libelle,
|
||||
description: procedure.description,
|
||||
state: 'brouillon',
|
||||
|
@ -123,7 +123,7 @@ describe API::V2::GraphqlController do
|
|||
expect(gql_errors).to eq(nil)
|
||||
expect(gql_data).to eq(demarche: {
|
||||
id: procedure.to_typed_id,
|
||||
number: procedure.id.to_s,
|
||||
number: procedure.id,
|
||||
dossiers: {
|
||||
nodes: [{ id: dossier1.to_typed_id }, { id: dossier.to_typed_id }]
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ describe API::V2::GraphqlController do
|
|||
expect(gql_errors).to eq(nil)
|
||||
expect(gql_data).to eq(dossier: {
|
||||
id: dossier.to_typed_id,
|
||||
number: dossier.id.to_s,
|
||||
number: dossier.id,
|
||||
state: 'en_construction',
|
||||
updatedAt: dossier.updated_at.iso8601,
|
||||
datePassageEnConstruction: dossier.en_construction_at.iso8601,
|
||||
|
|
Loading…
Reference in a new issue