package main
import ( "database/sql" "fmt" "time" "github.com/dosco/super-graph/core" _ "github.com/jackc/pgx/v4/stdlib" )
func main() { db, err := sql.Open("pgx", "postgres://postgrs:@localhost:5432/example_db") if err != nil { log.Fatal(err) }
sg, err := core.NewSuperGraph(nil, db)
if err != nil {
log.Fatal(err)
}
// And here's the GraphQL query to fetch posts, comments, author, etc
query := `
query {
posts {
id
title
body
comments(limit: 5) {
id
user {
id
name
}
}
user {
id
name
}
}
}`
res, err := sg.GraphQL(context.Background(), query, nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(res.Data))
}https://github.com/dosco/super-graph