Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api-headless-cms-ddb-es): entry values modifier #3422

Conversation

brunozoric
Copy link
Contributor

@brunozoric brunozoric commented Jul 14, 2023

Changes

This PR adds the CMS Entry Values Modifier plugin via which users can modify what exactly goes into the Elasticsearch index.

This is basically meant to be used in apps using the CMS storage but having their own GraphQL schema.

How Has This Been Tested?

Jest and manually.

Usage

import { createCmsEntryElasticsearchValuesModifier } from "@webiny/api-headless-cms-ddb-es";
const plugin = createCmsEntryElasticsearchValuesModifier({
    models: ["targetedModelId"],
    modifier: ({ setValues, values }) => {
        const title = `Audit log: ${values.title}`;
        // we set the values using the `setValues` function
        // in the prev object, there are values set by other plugins, if any.
        setValues(prev => {
            // Note that a field you are setting MUST exist in the model.
            return {
                // This will only make title be written into the Elasticsearch index.
                title
            };
        });
    }
});
// register the plugin as you would every other

@brunozoric brunozoric added this to the 5.37.1 milestone Jul 19, 2023
@brunozoric brunozoric changed the base branch from next to dev July 31, 2023 08:43
@brunozoric brunozoric marked this pull request as ready for review July 31, 2023 08:44
@brunozoric brunozoric changed the base branch from dev to next July 31, 2023 08:52
Copy link
Collaborator

@Pavel910 Pavel910 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at those return types. The rest seems fine.

packages/api-elasticsearch/src/compression.ts Outdated Show resolved Hide resolved
packages/api-elasticsearch/src/compression.ts Outdated Show resolved Hide resolved
@brunozoric brunozoric requested a review from Pavel910 July 31, 2023 14:08
@brunozoric brunozoric merged commit 267d852 into next Aug 1, 2023
58 checks passed
@brunozoric brunozoric deleted the bruno/feat/api-headless-cms-ddb-es/elasticsearch-values-modifier branch September 12, 2023 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants