Selaa lähdekoodia

Resolver

- add db
- refactoring
Alexey Kim 2 vuotta sitten
vanhempi
commit
453f440dba
2 muutettua tiedostoa jossa 23 lisäystä ja 10 poistoa
  1. 16 0
      graphql/query_location.go
  2. 7 10
      graphql/resolver_impl.go

+ 16 - 0
graphql/query_location.go

@@ -0,0 +1,16 @@
+package graphql
+
+import (
+	"context"
+	"gshopper.com/gshopify/shop/graphql/generated"
+)
+
+func (r *entityResolver) FindLocationByID(ctx context.Context, id string) (*generated.Location, error) {
+	panic("not implemented")
+}
+
+func (r *queryResolver) Locations(ctx context.Context,
+	after *string, before *string, first *int, last *int, near *generated.GeoCoordinateInput, reverse *bool, sortKey *generated.LocationSortKeys,
+) (*generated.LocationConnection, error) {
+	panic("not implemented")
+}

+ 7 - 10
graphql/resolver_impl.go

@@ -2,26 +2,23 @@ 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{}
 
-	return &r, nil
-}
-
-func (r *entityResolver) FindLocationByID(ctx context.Context, id string) (*generated.Location, error) {
-	panic("not implemented")
-}
+	var err error
+	if r.db, err = db.New(ctx, debug); err != nil {
+		return nil, err
+	}
 
-func (r *queryResolver) Locations(ctx context.Context,
-	after *string, before *string, first *int, last *int, near *generated.GeoCoordinateInput, reverse *bool, sortKey *generated.LocationSortKeys,
-) (*generated.LocationConnection, error) {
-	panic("not implemented")
+	return &r, nil
 }
 
 // Entity returns EntityResolver implementation.