123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package graphql
- import (
- "context"
- "gshopper.com/gshopify/products/db"
- "gshopper.com/gshopify/products/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
- }
- // Query returns QueryResolver implementation.
- func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} }
- // Product returns ProductResolver implementation.
- func (r *Resolver) Product() generated.ProductResolver { return &productResolver{r} }
- // ProductVariant returns ProductVariantResolver implementation.
- func (r *Resolver) ProductVariant() generated.ProductVariantResolver {
- return &productVariantResolver{r}
- }
- // Collection returns CollectionResolver implementation.
- func (r *Resolver) Collection() generated.CollectionResolver { return &collectionResolver{r} }
- func (r *Resolver) Close() error {
- var err error
- if r.db != nil {
- err = r.db.Close()
- }
- return err
- }
- type queryResolver struct{ *Resolver }
- type productResolver struct{ *Resolver }
- type productVariantResolver struct{ *Resolver }
- type collectionResolver struct{ *Resolver }
|