package graphql import ( "context" "gshopper.com/gshopify/shop/db" "gshopper.com/gshopify/shop/graphql/generated" ) type Resolver struct { db db.Database } func New(ctx context.Context, debug bool) (*Resolver, error) { r := Resolver{} var err error if r.db, err = db.New(ctx, debug); err != nil { return nil, err } return &r, nil } // Entity returns EntityResolver implementation. func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } // Query returns QueryResolver implementation. func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } func (r *Resolver) Close() error { var err error if r.db != nil { err = r.db.Close() } return err } type entityResolver struct{ *Resolver } type queryResolver struct{ *Resolver }