r1tsuu

fields select

by r1tsuu
payload-enchants
APIs & SDKs
v3
^3.0.0-beta.61
MIT

Overview

Summary generated from the README

Adds field selection to Payload's Local API and REST API responses, so only the requested fields are returned. Selection is set through a context option in the Local API or a select query parameter in REST. It also supports a defaultSelect option on relationship fields to limit which fields get populated. Designed for Payload 3.0 beta.

Features

  • Select fields in Local API calls through the context select option
  • Select fields in REST requests with the select query parameter
  • Supports nested group fields, array fields and populated relationship fields
  • defaultSelect option on relationship fields limits populated data
  • Reduces response payload size for interrelated pages

Use cases

  • Reduce page data size when documents reference each other through relationships
  • Fetch only id, slug and title from linked documents in navigation or link fields
  • Return GraphQL-like trimmed responses from REST and Local API queries

Installation

npm i @payload-enchants/fields-select

335

Stars

28

Forks

28

Open Issues

1 years ago

Last Updated

41

Weekly Downloads

v1.2.2

npm Version

39.1 KB

Unpacked Size

0

Dependencies

Repository stars

335+2 since Sep 7

Show data
Repository stars by day (UTC)
DateStars
Dec 6, 2026335
Dec 5, 2026335
Dec 4, 2026335
Dec 3, 2026335
Dec 2, 2026335
Dec 1, 2026335
Nov 30, 2026335
Nov 29, 2026335
Nov 28, 2026335
Nov 27, 2026335
Nov 26, 2026335
Nov 25, 2026335
Nov 24, 2026335
Nov 23, 2026335
Nov 22, 2026335
Nov 21, 2026335
Nov 20, 2026335
Nov 19, 2026336
Nov 18, 2026336
Nov 17, 2026335
Nov 16, 2026335
Nov 15, 2026335
Nov 14, 2026335
Nov 13, 2026335
Nov 12, 2026335
Nov 11, 2026335
Nov 10, 2026335
Nov 9, 2026335
Nov 8, 2026335
Nov 7, 2026335
Nov 6, 2026335
Nov 5, 2026335
Nov 4, 2026335
Nov 3, 2026335
Nov 2, 2026335
Nov 1, 2026335
Oct 31, 2026335
Oct 30, 2026335
Oct 29, 2026335
Oct 28, 2026335
Oct 27, 2026335
Oct 26, 2026335
Oct 25, 2026335
Oct 24, 2026334
Oct 23, 2026334
Oct 22, 2026334
Oct 21, 2026334
Oct 20, 2026334
Oct 19, 2026334
Oct 18, 2026334
Oct 17, 2026334
Oct 16, 2026334
Oct 15, 2026334
Oct 14, 2026334
Oct 13, 2026334
Oct 12, 2026334
Oct 11, 2026333
Oct 10, 2026333
Oct 9, 2026333
Oct 8, 2026333
Oct 7, 2026333
Oct 6, 2026333
Oct 5, 2026333
Oct 4, 2026333
Oct 3, 2026333
Oct 2, 2026333
Oct 1, 2026333
Sep 30, 2026333
Sep 29, 2026333
Sep 28, 2026333
Sep 27, 2026333
Sep 26, 2026333
Sep 25, 2026333
Sep 24, 2026333
Sep 23, 2026333
Sep 22, 2026333
Sep 21, 2026333
Sep 20, 2026333
Sep 19, 2026333
Sep 18, 2026333
Sep 17, 2026333
Sep 16, 2026333
Sep 15, 2026333
Sep 14, 2026333
Sep 13, 2026333
Sep 12, 2026333
Sep 11, 2026333
Sep 10, 2026333
Sep 9, 2026333
Sep 8, 2026333
Sep 7, 2026333

Shared by 7 plugins in r1tsuu/payload-enchants.

npm weekly downloads

41−2.4K since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202641
Dec 5, 202646
Dec 4, 202637
Dec 3, 202629
Dec 2, 202624
Dec 1, 202624
Nov 30, 202623
Nov 29, 202631
Nov 28, 202634
Nov 27, 202633
Nov 26, 202638
Nov 25, 202638
Nov 24, 202638
Nov 23, 202637
Nov 22, 202633
Nov 21, 202627
Nov 20, 202681
Nov 19, 2026133
Nov 18, 2026142
Nov 17, 2026156
Nov 16, 2026180
Nov 15, 2026187
Nov 14, 2026204
Nov 13, 2026161
Nov 12, 2026129
Nov 11, 2026162
Nov 10, 2026170
Nov 9, 2026160
Nov 8, 2026171
Nov 7, 2026165
Nov 6, 2026167
Nov 5, 2026148
Nov 4, 2026120
Nov 3, 202696
Nov 2, 202692
Nov 1, 2026106
Oct 31, 2026114
Oct 30, 2026111
Oct 29, 2026104
Oct 28, 202686
Oct 27, 202690
Oct 26, 202693
Oct 25, 202671
Oct 24, 202655
Oct 23, 202639
Oct 22, 202651
Oct 21, 202656
Oct 20, 202655
Oct 19, 202648
Oct 18, 202650
Oct 17, 202647
Oct 16, 2026117
Oct 15, 2026125
Oct 14, 2026142
Oct 13, 2026142
Oct 12, 2026138
Oct 11, 2026142
Oct 10, 2026906
Oct 9, 20261,280
Oct 8, 20261,712
Oct 7, 20262,446
Oct 6, 20262,995
Oct 5, 20263,693
Oct 4, 20265,662
Oct 3, 20266,749
Oct 2, 202612,348
Oct 1, 202617,972
Sep 30, 202621,255
Sep 29, 202621,932
Sep 28, 202622,869
Sep 27, 202621,095
Sep 26, 202619,668
Sep 25, 202614,318
Sep 24, 20269,056
Sep 23, 20265,277
Sep 22, 20264,238
Sep 21, 20262,757
Sep 20, 20267,859
Sep 19, 202610,069
Sep 18, 20269,833
Sep 17, 20269,606
Sep 16, 20269,671
Sep 15, 202610,809
Sep 14, 202611,191
Sep 13, 20266,035
Sep 12, 20263,637
Sep 11, 20263,744
Sep 10, 20263,350
Sep 9, 20263,285
Sep 8, 20262,241
Sep 7, 20262,439

Each point is npm's rolling 7-day download count.

Health Score

48/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/684372049-fields-select.svg)](https://payloaddirectory.dev/plugins/684372049-fields-select)
HTML
<a href="https://payloaddirectory.dev/plugins/684372049-fields-select"><img src="https://payloaddirectory.dev/badge/684372049-fields-select.svg" alt="Payload Directory"></a>
Updated Jan 4, 2025Created Aug 29, 2023Published Jul 16, 2024

README

Fields select plugin for Payload 3.0

Install

pnpm add @payload-enchants/fields-select

In your payload.config.ts:

/// ....
import { fieldsSelect } from '@payload-enchants/fields-select';

export default buildConfig({
  // ...
  plugins: [fieldsSelect()],
});

Description

Adds an option to select fields from Local API / REST API response like with GraphQL As well solves a problem, when you need only specific fields to populate from relationship field with defaultSelect option Could significally reduce your pages data sizes, especially when they are related to each other. PR with more powerful version of this to Payload - https://github.com/payloadcms/payload/pull/5942

Usage

Local API:

/** As well findByID **/
payload.find({
  collection: 'posts',
  context: {
    /**
     * Selects:
     * top level id, title fields
     * text field from "nestedGroup" group field
     * all fields from "nestedArray" field
     * "title" field from populated relationship document
     **/
    select: ['id', 'title', 'nestedGroup.text', 'nestedArray', 'relationship.title'],
  },
});

REST API:

Use select query parameter, example: ?select[0]=id&select[1]=title

Default Select option for relationship fields

const linkField: RelationshipField = {
  custom: {
    /** Field will be populated only with id, slug and title fields **/
    defaultSelect: ['id', 'slug', 'title'],
  },
  name: 'link',
  relationTo: 'pages',
};

Similar plugins