category

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ListResponseType = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Categories",
		Fields: graphql.Fields{
			"_inbox": &graphql.Field{
				Type:    graphql.Int,
				Resolve: statusResolver("inbox"),
			},
			"_to_read": &graphql.Field{
				Type:    graphql.Int,
				Resolve: statusResolver("to_read"),
			},
			"_starred": &graphql.Field{
				Type: graphql.Int,
				Resolve: func(p graphql.ResolveParams) (interface{}, error) {
					starred := true
					req := model.ArticlesPageRequest{
						Starred: &starred,
					}
					return service.Lookup().CountCurrentUserArticles(p.Context, req)
				},
			},
			"entries": &graphql.Field{
				Type: graphql.NewList(Type),
			},
		},
	},
)

ListResponseType is a list of categories

View Source
var Type = graphql.NewObject(
	graphql.ObjectConfig{
		Name: "Category",
		Fields: graphql.Fields{
			"id": &graphql.Field{
				Type: graphql.Int,
			},
			"title": &graphql.Field{
				Type:        graphql.String,
				Description: "title of the category",
			},
			"inbox": &graphql.Field{
				Type:        graphql.Int,
				Description: "number of received articles for this category",
				Resolve: func(p graphql.ResolveParams) (interface{}, error) {
					var category = model.Category{}
					switch p.Source.(type) {
					case model.Category:
						category, _ = p.Source.(model.Category)
					case *model.Category:
						cat, _ := p.Source.(*model.Category)
						category = *cat
					default:
						return nil, errors.New("no category received by inbox resolver")
					}
					status := "inbox"
					req := model.ArticlesPageRequest{
						Category: category.ID,
						Status:   &status,
					}
					return service.Lookup().CountCurrentUserArticles(p.Context, req)
				},
			},
			"created_at": &graphql.Field{
				Type:        graphql.DateTime,
				Description: "creation date",
			},
			"updated_at": &graphql.Field{
				Type:        graphql.DateTime,
				Description: "modification date",
			},
		},
	},
)

Type of a category

Functions

func CategoriesResolver

func CategoriesResolver(p graphql.ResolveParams) (interface{}, error)

CategoriesResolver is the resolver for retrieve categories

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL