// Code generated by ent, DO NOT EDIT. package ent import ( "context" "github.com/99designs/gqlgen/graphql" ) func (c *Category) Posts( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy *PostOrder, where *PostWhereInput, ) (*PostConnection, error) { opts := []PostPaginateOption{ WithPostOrder(orderBy), WithPostFilter(where.Filter), } alias := graphql.GetFieldContext(ctx).Field.Alias totalCount, hasTotalCount := c.Edges.totalCount[0][alias] if nodes, err := c.NamedPosts(alias); err == nil || hasTotalCount { pager, err := newPostPager(opts, last != nil) if err != nil { return nil, err } conn := &PostConnection{Edges: []*PostEdge{}, TotalCount: totalCount} conn.build(nodes, pager, after, first, before, last) return conn, nil } return c.QueryPosts().Paginate(ctx, after, first, before, last, opts...) } func (po *Post) Category(ctx context.Context) (*Category, error) { result, err := po.Edges.CategoryOrErr() if IsNotLoaded(err) { result, err = po.QueryCategory().Only(ctx) } return result, MaskNotFound(err) } func (po *Post) Profile(ctx context.Context) (*Profile, error) { result, err := po.Edges.ProfileOrErr() if IsNotLoaded(err) { result, err = po.QueryProfile().Only(ctx) } return result, MaskNotFound(err) } func (pr *Profile) Posts( ctx context.Context, after *Cursor, first *int, before *Cursor, last *int, orderBy *PostOrder, where *PostWhereInput, ) (*PostConnection, error) { opts := []PostPaginateOption{ WithPostOrder(orderBy), WithPostFilter(where.Filter), } alias := graphql.GetFieldContext(ctx).Field.Alias totalCount, hasTotalCount := pr.Edges.totalCount[0][alias] if nodes, err := pr.NamedPosts(alias); err == nil || hasTotalCount { pager, err := newPostPager(opts, last != nil) if err != nil { return nil, err } conn := &PostConnection{Edges: []*PostEdge{}, TotalCount: totalCount} conn.build(nodes, pager, after, first, before, last) return conn, nil } return pr.QueryPosts().Paginate(ctx, after, first, before, last, opts...) }