Created controller and route to answer GraphQL queries
This commit is contained in:
11
app/controllers/graphql_controller.rb
Normal file
11
app/controllers/graphql_controller.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user