vendure-ecommerce/vendure

CustomFields that are mutable only on a certain API

Closed this issue · 3 comments

Is your feature request related to a problem? Please describe.
One of the things I would find useful is to have a custom field property that would define the graphql apis the property can be mutated by. E.g. mutable: ['admin', 'shop']. If not mutable: [ 'admin'], it would not be mutable on shop api, trying to mutate it there throws an error.

Describe the solution you'd like
Our issue occurs with things like discounts that we implement in a customized way. These get set on OrderLines through a custom cart editor add on, so not something we want to do server side. But these discounts should only be available to the admins

Describe alternatives you've considered
We're locking down our apis for direct access, so, direct graphql mutations would be harder, but not impossible to do.
This might be possible to achieve through the Permissions input

Does the "requiresPermission" option not cover what you need?

https://docs.vendure.io/guides/developer-guide/custom-fields/#requirespermission

I guess that covers the admin API specifically, but the public property (https://docs.vendure.io/guides/developer-guide/custom-fields/#public) should cover the shop API

Alternatively, you could set it readonly and then all default APIs will disallow editing and only the custom ones you write will have that ability