GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
593 B

  1. package queries
  2. import (
  3. "context"
  4. "git.aiterp.net/rpdata/api/graphql/resolver/types"
  5. "git.aiterp.net/rpdata/api/model/log"
  6. )
  7. // PostsArgs is args for the posts query
  8. type PostsArgs struct {
  9. IDs []string
  10. }
  11. // Posts resolves the posts query
  12. func (r *QueryResolver) Posts(ctx context.Context, args *PostsArgs) ([]*types.PostResolver, error) {
  13. posts, err := log.ListPostIDs(args.IDs...)
  14. if err != nil {
  15. return nil, err
  16. }
  17. resolvers := make([]*types.PostResolver, len(posts))
  18. for i := range resolvers {
  19. resolvers[i] = &types.PostResolver{P: posts[i]}
  20. }
  21. return resolvers, nil
  22. }