Created controller and route to answer GraphQL queries

This commit is contained in:
Alberto Miedes Garcés
2016-09-28 12:47:07 +02:00
parent df5caea56f
commit ab333d6627
2 changed files with 16 additions and 0 deletions

View File

@@ -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

View File

@@ -262,6 +262,11 @@ Rails.application.routes.draw do
end end
end end
# GraphQL
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/queries"
post '/queries', to: 'graphql#query'
if Rails.env.development? if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener" mount LetterOpenerWeb::Engine, at: "/letter_opener"
end end