123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package graphql
- import (
- "context"
- "github.com/gshopify/service-wrapper/fun"
- "github.com/gshopify/service-wrapper/model"
- "github.com/gshopify/service-wrapper/server/middleware"
- "github.com/microcosm-cc/bluemonday"
- "gshopper.com/gshopify/products/graphql/generated"
- "gshopper.com/gshopify/products/graphql/helper"
- )
- func (r *queryResolver) Collections(ctx context.Context, after *string, before *string, first *int, last *int, query *string, reverse *bool, sort *generated.CollectionSortKeys) (*generated.CollectionConnection, error) {
- panic("not implemented")
- }
- func (r *productResolver) Collections(ctx context.Context, product *generated.Product,
- after *string, before *string, first *int, last *int, reverse *bool) (*generated.CollectionConnection, error) {
- var (
- inContext *middleware.GShopifyContext
- collections []*generated.Collection
- err error
- )
- if inContext, err = middleware.InContext(ctx); err != nil {
- return nil, err
- }
- rawId, err := model.ParseId(model.GidProduct, product.ID)
- if err != nil {
- return nil, err
- }
- if collections, err = r.db.ProductCollections(inContext.Language, rawId); err != nil {
- return nil, err
- }
- return helper.NewCollectionConnection(collections, after, before, first, last, reverse)
- }
- func (r *collectionResolver) Description(_ context.Context, collection *generated.Collection, truncateAt *int) (string, error) {
- return fun.TruncateAt(
- bluemonday.StrictPolicy().Sanitize(string(collection.DescriptionHTML)),
- truncateAt)
- }
|