Adds field selection to Payload's Local API and REST API so responses contain only the requested fields. Selection is passed through the request context in the Local API or a select query parameter in REST. Relationship fields can also define a default select list through a custom option to limit populated data. Built for Payload 3.0 beta.
Installation
npm i @payload-enchants/fields-select334
Stars
28
Forks
28
Open Issues
1 years ago
Last Updated
26
Weekly Downloads
v1.2.2
npm Version
39.1 KB
Unpacked Size
0
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Shared by 7 plugins in r1tsuu/payload-enchants.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/684372049-fields-select)<a href="https://payloaddirectory.dev/plugins/684372049-fields-select"><img src="https://payloaddirectory.dev/badge/684372049-fields-select.svg" alt="Payload Directory"></a>README
pnpm add @payload-enchants/fields-select
In your payload.config.ts:
/// ....
import { fieldsSelect } from '@payload-enchants/fields-select';
export default buildConfig({
// ...
plugins: [fieldsSelect()],
});
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
/** 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'],
},
});
Use select query parameter, example:
?select[0]=id&select[1]=title
const linkField: RelationshipField = {
custom: {
/** Field will be populated only with id, slug and title fields **/
defaultSelect: ['id', 'slug', 'title'],
},
name: 'link',
relationTo: 'pages',
};
mcp
Adds Model Context Protocol capabilities to Payload so AI clients can work with your CMS
9889.1k/wk45.4kv3
payload plugin openapi
Generate OpenAPI 3.0, 3.1 or 3.2 specs from your Payload config and serve them with Scalar or Swagger UI
80437/wk18v4
payload oapi
Generate an OpenAPI 3.0 or 3.1 spec from your Payload config with optional documentation UIs
670/wk125v3
payload plugin translator
Translate localized Payload content with an AI provider from document, collection or field controls in the admin
550/wk29v3
payload assist
DTO utilities and config validation rules to control what Payload endpoints and collection reads return
539/wk0v3
payload plugin api guide
Generates a live API reference and agent-readable query guide from your Payload configuration
480/wk2v3