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

allowing :discard_nils option to be passed to optional inputs #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

assembler
Copy link

Sometimes i want optional attributes, but if passed, i want them to be required.

Example:

Users::Update.run! id: 1, name: "Zoga", role: "admin" # would update both name and role
Users::Update.run! id: 1, role: "power_admin" # would update only role
Users::Update.run! id: 1, name: nil # would raise validation error

Both :name and :role are optional inputs. But if name is passed as nil, it shouldn't be discarded (current behavior).

@openface
Copy link

+1 for this feature. This option would cover the case raised in #47 for me.

@openface
Copy link

Just adding another word of support for this pull request.

As it stands today in my app, users are able to send a nil value to a field that cannot be unset; and since the mutation discards it, this results in a successful response back to the user, but without any change made to the field in the database. This pull request would permit the mutation to invalidate the nil input, which would meet the business requirement for this field.

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

Successfully merging this pull request may close these issues.

2 participants