1234567891011121314151617181920212223242526272829303132333435363738394041 |
- 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 }
|