diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb new file mode 100644 index 000000000..11accf52a --- /dev/null +++ b/app/controllers/graphql_controller.rb @@ -0,0 +1,11 @@ +class GraphqlController < ApplicationController + + def query + #puts "I'm the GraphqlController inside the #query action!!" + + render json: ConsulSchema.execute( + params[:query], + variables: params[:variables] || {} + ) + end +end diff --git a/config/routes.rb b/config/routes.rb index df1a7c6fb..b86cb0c30 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -262,6 +262,11 @@ Rails.application.routes.draw do end end + # GraphQL + mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/queries" + post '/queries', to: 'graphql#query' + + if Rails.env.development? mount LetterOpenerWeb::Engine, at: "/letter_opener" end