package queries import ( "context" "errors" "git.aiterp.net/rpdata/api/models" "git.aiterp.net/rpdata/api/models/posts" ) func (r *resolver) Post(ctx context.Context, id string) (models.Post, error) { return posts.FindID(id) } func (r *resolver) Posts(ctx context.Context, filter *posts.Filter) ([]models.Post, error) { // Some sanity checks to avoid querying an insame amount of posts. if filter == nil { filter = &posts.Filter{Limit: 256} } else { if (filter.Limit <= 0 || filter.Limit > 256) && filter.LogID == nil { return nil, errors.New("a limit of 0 (no limit) or >256 without a logId is not allowed") } if len(filter.Kind) > 32 { return nil, errors.New("You cannot specify more than 32 kinds") } if len(filter.ID) > 32 { return nil, errors.New("You cannot specify more than 32 IDs") } } return posts.List(filter) }