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

Revisit argument / input_object validation #4810

Open
rmosolgo opened this issue Jan 26, 2024 · 0 comments
Open

Revisit argument / input_object validation #4810

rmosolgo opened this issue Jan 26, 2024 · 0 comments

Comments

@rmosolgo
Copy link
Owner

rmosolgo commented Jan 26, 2024

Looking through it now, it seems like I could do better on this:

maybe_raise_if_invalid(ast_value) do
merge_results([
required_input_fields_are_present(type, ast_value),
present_input_field_values_are_valid(type, ast_value)
])
end

required_fields = context.warden.arguments(parent_type)
.select{|arg| arg.type.kind.non_null?}
.map!(&:graphql_name)
present_fields = ast_node.arguments.map(&:name)
missing_fields = required_fields - present_fields
missing_fields.each do |missing_field|

Could those be DRY'd? Maybe this is part of the larger review of input validation mentioned in #2994, see also #3459

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

1 participant