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.
Click to show internal directories.
Click to hide internal directories.