GraphQL playground only minify in production mode #34
|
@ -7,7 +7,15 @@ module Backend
|
|||
class WebServer
|
||||
include Router
|
||||
|
||||
GRAPHQL_PLAYGROUND = {{ run("./macros/minify_html.cr", read_file("#{__DIR__}/playground.html")).stringify }}
|
||||
GRAPHQL_PLAYGROUND = {{ flag?(:development) ? read_file("#{__DIR__}/playground.html") : run("./macros/minify_html.cr", read_file("#{__DIR__}/playground.html")).stringify }}
|
||||
|
||||
struct GraphQLQueryData
|
||||
include JSON::Serializable
|
||||
|
||||
property query : String
|
||||
property variables : Hash(String, JSON::Any)?
|
||||
property operation_name : String?
|
||||
end
|
||||
|
||||
def draw_routes : Nil
|
||||
# enable graphql playground when in development mode or explicitly enabled
|
||||
|
@ -16,7 +24,7 @@ module Backend
|
|||
|
||||
get "/" do |context|
|
||||
context.response.content_type = "text/html"
|
||||
context.response.print(GRAPHQL_PLAYGROUND)
|
||||
context.response.puts(GRAPHQL_PLAYGROUND)
|
||||
|
||||
context
|
||||
end
|
||||
|
@ -53,14 +61,6 @@ module Backend
|
|||
server.bind_tcp("0.0.0.0", 80, true)
|
||||
server.listen
|
||||
end
|
||||
|
||||
private struct GraphQLQueryData
|
||||
include JSON::Serializable
|
||||
|
||||
property query : String
|
||||
property variables : Hash(String, JSON::Any)?
|
||||
property operation_name : String?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue