From 7a8fd3c679a02965a4667e295e39e847623beb4e Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 9 Apr 2020 12:41:35 +0200 Subject: [PATCH] Use graphql playground instead of graphiql --- Gemfile | 2 +- Gemfile.lock | 7 ++- config/initializers/graphiql.rb | 81 --------------------------------- config/initializers/graphql.rb | 7 +++ config/routes.rb | 2 +- 5 files changed, 12 insertions(+), 87 deletions(-) delete mode 100644 config/initializers/graphiql.rb diff --git a/Gemfile b/Gemfile index 55ba93826..14407ddc5 100644 --- a/Gemfile +++ b/Gemfile @@ -31,10 +31,10 @@ gem 'flipper-ui' gem 'fugit' gem 'geocoder' gem 'gon' -gem 'graphiql-rails' gem 'graphql' gem 'graphql-batch' gem 'graphql-rails_logger' +gem 'graphql_playground-rails' gem 'groupdate' gem 'haml-rails' gem 'hashie' diff --git a/Gemfile.lock b/Gemfile.lock index 224ba4f58..7e80e2d2b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -248,9 +248,6 @@ GEM i18n (>= 0.7) multi_json request_store (>= 1.0) - graphiql-rails (1.7.0) - railties - sprockets-rails graphql (1.10.6) graphql-batch (0.4.2) graphql (>= 1.3, < 2) @@ -264,6 +261,8 @@ GEM bundler (>= 1.14) graphql (~> 1.10) thor (>= 0.19, < 2.0) + graphql_playground-rails (2.1.0) + rails (>= 5.1.0) groupdate (5.0.0) activesupport (>= 5) guard (2.15.0) @@ -755,11 +754,11 @@ DEPENDENCIES fugit geocoder gon - graphiql-rails graphql graphql-batch graphql-rails_logger graphql-schema_comparator + graphql_playground-rails groupdate guard guard-livereload diff --git a/config/initializers/graphiql.rb b/config/initializers/graphiql.rb deleted file mode 100644 index b67ca0c50..000000000 --- a/config/initializers/graphiql.rb +++ /dev/null @@ -1,81 +0,0 @@ -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://www.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 { - file { - 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' diff --git a/config/initializers/graphql.rb b/config/initializers/graphql.rb index e669da38b..dbf0da270 100644 --- a/config/initializers/graphql.rb +++ b/config/initializers/graphql.rb @@ -3,3 +3,10 @@ GraphQL::RailsLogger.configure do |config| 'API::V2::GraphqlController' => ['execute'] } end + +GraphqlPlayground::Rails.configure do |config| + config.title = "demarches-simplifiees.fr" + config.settings = { + "schema.polling.enable": false + } +end diff --git a/config/routes.rb b/config/routes.rb index 35f560b5c..456bb92fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -224,7 +224,7 @@ Rails.application.routes.draw do # authenticated :user, lambda { |user| user.administrateur_id && Flipper.enabled?(:administrateur_graphql, user) } do - mount GraphiQL::Rails::Engine, at: "/graphql", graphql_path: "/api/v2/graphql", via: :get + mount GraphqlPlayground::Rails::Engine, at: "/graphql", graphql_path: "/api/v2/graphql" end namespace :api do