Skip to content
Snippets Groups Projects

WIP: Resolve "Implement Client API GVA : GraphQL Verification Api"

Closed Éloïs requested to merge ji_emme/89-implement-client-api-gva-graphql-verification-api into dev

Closes #89 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Éloïs
  • Éloïs
  • Éloïs
  • Éloïs
  • 236 if stop {
    237 break;
    238 }
    239 }
    240 Err(e) => {
    241 // Log error
    242 warn!("{}", e);
    243 break;
    244 }
    245 }
    246 }
    247 });
    248
    249 let smd: SoftwareMetaDatas<DuRsConf> = soft_meta_datas.clone();
    250 thread::spawn(move || {
    251 let _ = webserver::start_web_server(&smd);
  • Éloïs
  • Éloïs
  • Éloïs
  • Éloïs
    Éloïs @librelois started a thread on the diff
  • 1 // Copyright (C) 2018 The Duniter Project Developers.
    2 //
    3 // This program is free software: you can redistribute it and/or modify
    4 // it under the terms of the GNU Affero General Public License as
    5 // published by the Free Software Foundation, either version 3 of the
    6 // License, or (at your option) any later version.
    7 //
    8 // This program is distributed in the hope that it will be useful,
    9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11 // GNU Affero General Public License for more details.
    12 //
    13 // You should have received a copy of the GNU Affero General Public License
    14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
    15
  • Éloïs
  • 28 fn graphiql() -> HttpResponse {
    29 let html = graphiql_source("http://127.0.0.1:3000/graphql");
    30 println!("html { }", &html);
    31 HttpResponse::Ok()
    32 .content_type("text/html; charset=utf-8")
    33 .body(html)
    34 }
    35
    36 fn graphql(
    37 st: web::Data<Arc<Schema>>,
    38 data: web::Json<GraphQLRequest>,
    39 ) -> impl Future<Item = HttpResponse, Error = Error> {
    40 let context = crate::context::get_context();
    41 web::block(move || {
    42 let res = data.execute(&st, context);
    43 Ok::<_, serde_json::error::Error>(serde_json::to_string(&res)?)
    • L'erreur étant mappée en dessous par map_err puis retournée, le ? est superflue.

    • jm changed this line in version 21 of the diff

      changed this line in version 21 of the diff

    • quand je supprime le « ? » j’ai cette erreur de compilation

      @ji_emme c'est parce que tu demande explicitement au compilateur de retourner un Ok, ce qui n'a aucun sens puisque les cas d'erreurs sont gérés par le map_err juste en dessous. Pourquoi voulais tu retourner un Ok ? Plus généralement, le simple fait d'écrire un Ok::<T, E> explicite est une mauvaise pratique, la bonne façon est de retourner le Result et de traiter l'erreur plus loin.

    • Please register or sign in to reply
  • Éloïs
  • Éloïs
  • jm added 1 commit
  • jm added 1 commit

    added 1 commit

    • f5f0c0c8 - wip update juniper-from-schema

    Compare with previous version

  • jm added 1 commit

    added 1 commit

    Compare with previous version

  • jm added 11 commits

    added 11 commits

    Compare with previous version

  • jm added 1 commit

    added 1 commit

    • d6928152 - wip [docs] gva module : module documentation

    Compare with previous version

  • jm added 1 commit
  • jm added 1 commit
  • jm added 1 commit
  • jm added 17 commits

    added 17 commits

    Compare with previous version

  • jm added 1 commit

    added 1 commit

    Compare with previous version

  • 41 #[macro_use]
    42 extern crate structopt;
    43
    44 extern crate juniper;
    45
    46 mod context;
    47 mod schema;
    48 mod webserver;
    49
    50 use dubp_currency_params::CurrencyName;
    51 use durs_common_tools::fatal_error;
    52 use durs_common_tools::traits::merge::Merge;
    53 use durs_conf::DuRsConf;
    54 use durs_message::events::*;
    55 use durs_message::*;
    56 use durs_module::*;
  • jm added 1 commit

    added 1 commit

    • 8c38c8f8 - [ref] gva: corrections following review

    Compare with previous version

  • @ji_emme je t'ai ajouté la configuration du host et du port d'écoute, c'est sur la branche elois/gva-host-port, tu peut te rebaser dessus directement :)

  • Éloïs
    Éloïs @librelois started a thread on the diff
  • 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11 // GNU Affero General Public License for more details.
    12 //
    13 // You should have received a copy of the GNU Affero General Public License
    14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
    15
    16 //! Gva Module
    17 // This module provides a graphql API implementation of the 0003 RFC
    18 //
    19 // /src/schema.gql contains schema description
    20 // /src/schema.rs contains model and resolvers implementation
    21 // /src/webserver.rs contains web server implementaion based on actix-web
    22 //
    23 // Graphiql web client is accessible at
    24 // http://127.0.0.1:3000/graphiql
    • @ji_emme c'est bien mais il faut préfixer toutes les lignes par //!, pas seulement la première. Tu peut vérifier le rendu en générant la doc, commande cargo doc a la racine du projet (attention c'est très long a générer) Puis ouvre dans un navigateur le fichier target/doc/dunitrust/index.html

      Du coup quand tu aura récupérer ma feature de config du host et du port il faudra remplacer 127.0.0.1:3000 par host:port, en précisant les valeurs par défaut :)

    • Please register or sign in to reply
  • Éloïs
    Éloïs @librelois started a thread on the diff
  • 8
    9 [lib]
    10 path = "src/lib.rs"
    11
    12 [dependencies]
    13 proc-macro2 = "1.0.6"
    14 actix-web = "1.0.8"
    15 dubp-block-doc = { path = "../../dubp/block-doc"} #, version = "0.1.0" }
    16 durs-bc-db-reader = { path = "../../modules-lib/bc-db-reader" }
    17 durs-conf = { path = "../../core/conf" }
    18 durs-message = { path = "../../core/message" }
    19 durs-module = { path = "../../core/module" }
    20 durs-network = { path = "../../core/network" }
    21 dubp-common-doc = { path = "../../dubp/common-doc"} #, version = "0.1.0" }
    22 durs-common-tools = { path = "../../tools/common-tools" }
    23 dubp-currency-params = { path = "../../dubp/currency-params" }
  • Éloïs
    Éloïs @librelois started a thread on the diff
  • 14 actix-web = "1.0.8"
    15 dubp-block-doc = { path = "../../dubp/block-doc"} #, version = "0.1.0" }
    16 durs-bc-db-reader = { path = "../../modules-lib/bc-db-reader" }
    17 durs-conf = { path = "../../core/conf" }
    18 durs-message = { path = "../../core/message" }
    19 durs-module = { path = "../../core/module" }
    20 durs-network = { path = "../../core/network" }
    21 dubp-common-doc = { path = "../../dubp/common-doc"} #, version = "0.1.0" }
    22 durs-common-tools = { path = "../../tools/common-tools" }
    23 dubp-currency-params = { path = "../../dubp/currency-params" }
    24 failure = "0.1.5"
    25 futures = "0.1"
    26 futures-cpupool = "0.1"
    27 juniper = "0.14.0"
    28
    29 juniper-from-schema = "0.5.0"
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading