Skip to content

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