-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathconfig.ru
More file actions
44 lines (35 loc) · 1.13 KB
/
config.ru
File metadata and controls
44 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
# Rack configuration file for running GraphQL Docs as a web server
#
# This demonstrates using GraphQLDocs as a Rack application that serves
# documentation dynamically on-demand instead of pre-generating static files.
#
# Run with: rackup config.ru
# Or with specific port: rackup config.ru -p 9292
require_relative "lib/graphql-docs"
# Load the sample GraphQL schema
schema_path = File.join(__dir__, "test", "graphql-docs", "fixtures", "gh-schema.graphql")
unless File.exist?(schema_path)
puts "Error: Sample schema not found at #{schema_path}"
puts "Please ensure the schema file exists before starting the server."
exit 1
end
schema = File.read(schema_path)
# Create the Rack app
app = GraphQLDocs::App.new(
schema: schema,
options: {
base_url: "",
use_default_styles: true,
cache: true
}
)
# Log requests in development
use Rack::CommonLogger
# Add reloader for development (optional, requires 'rack' gem)
if ENV["RACK_ENV"] != "production"
puts "Running in development mode"
puts "Visit http://localhost:9292 to view the documentation"
puts "Press Ctrl+C to stop the server"
end
run app