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

elastic-search: hide customProductMappings from api #1181

Closed
Draykee opened this issue Oct 20, 2021 · 3 comments
Closed

elastic-search: hide customProductMappings from api #1181

Draykee opened this issue Oct 20, 2021 · 3 comments

Comments

@Draykee
Copy link
Contributor

Draykee commented Oct 20, 2021

Is your feature request related to a problem? Please describe.
I want to map and search for some custom products properties without exposing the exact value to the public api.

Usecases:

  • A hidden rank that is applied to promote some products
  • A hidden product owner id (I never want to expose user ids)
  • Exact product locations

Describe the solution you'd like
Extend the custom mapping type with a new field:

type CustomMappingDefinition<Args extends any[], T extends CustomMappingTypes, R> = {
    graphQlType: T;
    hidden?: boolean; // **NEW** ( should default to false )
    valueFn: (...args: Args) => R;
}

And inside the generateCustomMappingTypes function a filter could just be applied like this:

const productMappings = Object.entries(options.customProductMappings || {}).filter(([, value]) => !value.hidden);

Describe alternatives you've considered
I couldn't come up with an alternative that doesn't produce a huge overhead.

@michaelbromley
Copy link
Member

This is a good point and can be added to the next minor release. Only thing I'd suggest is to change it from hidden: true to public: false to align with the existing custom fields API.

@Draykee
Copy link
Contributor Author

Draykee commented Nov 9, 2021

@michaelbromley I guess this issue can be closed :)

@michaelbromley
Copy link
Member

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants