-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
51 lines (43 loc) · 1.28 KB
/
main.go
File metadata and controls
51 lines (43 loc) · 1.28 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
45
46
47
48
49
50
51
package main
import (
"context"
"log"
"time"
"github.com/xraph/forge"
"github.com/xraph/forge/extensions/graphql"
)
func main() {
// Create Forge application
app := forge.NewApp(forge.DefaultAppConfig())
// Register GraphQL extension with configuration
gqlExt := graphql.NewExtension(
graphql.WithEndpoint("/graphql"),
graphql.WithPlayground(true),
graphql.WithIntrospection(true),
graphql.WithMaxComplexity(1000),
graphql.WithQueryCache(true, 5*time.Minute),
graphql.WithMetrics(true),
graphql.WithTracing(true),
)
if err := app.RegisterExtension(gqlExt); err != nil {
log.Fatalf("Failed to register GraphQL extension: %v", err)
}
// Start the application
if err := app.Start(context.Background()); err != nil {
log.Fatalf("Failed to start app: %v", err)
}
log.Println("🚀 GraphQL server is running!")
log.Println("📊 GraphQL endpoint: http://localhost:8080/graphql")
log.Println("🎮 Playground: http://localhost:8080/playground")
log.Println("")
log.Println("Example queries:")
log.Println(" { hello(name: \"World\") }")
log.Println(" { version }")
log.Println("")
log.Println("Example mutations:")
log.Println(" mutation { echo(message: \"Hello\") }")
// Run server
if err := app.Run(); err != nil {
log.Fatalf("Server error: %v", err)
}
}