Skip to content
Snippets Groups Projects
Commit 2f07fef1 authored by Brett Walker's avatar Brett Walker
Browse files

Fix arg handlling in GraphQL::Helpers

parent 910d7b74
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,6 @@ def resolve_field(
parent = object_type.authorized_new(object, query_ctx)
raise UnauthorizedObject unless parent
# TODO: This will need to change when we move to the interpreter:
# At that point, arguments will be a plain ruby hash rather than
# an Arguments object
# see: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27536
......@@ -118,20 +117,37 @@ def resolve_field(
defaults_used: []
)
# arguments = arguments.to_h.symbolize_keys
arguments = arguments.to_h.transform_keys! { |key| key.to_s.underscore }.symbolize_keys
# we enable the request store so we can track gitaly calls.
::Gitlab::WithRequestStore.with_request_store do
# TODO: This will need to change when we move to the interpreter - at that
# point we will call `field#resolve`
# Unwrap the arguments to mutations. This pairs with the wrapping in GraphqlHelpers#resolve
# If arguments are not wrapped first, then arguments processing will raise.
# If arguments are not unwrapped here, then the resolve method of the mutation will raise argument errors.
# arguments = arguments.to_kwargs[:input] if field.resolver && field.resolver <= ::Mutations::BaseMutation
# field.resolve_field(parent, arguments, query_ctx)
# binding.pry
# TODO: re-look at this and comments above
arguments = arguments.to_kwargs if field.resolver && field.resolver <= ::Mutations::BaseMutation
field.resolve(parent, arguments, query_ctx)
# arguments = arguments.to_kwargs if field.resolver && field.resolver <= ::Mutations::BaseMutation
if field.resolver && field.resolver <= ::Mutations::BaseMutation
args[:input] = GraphQL::Schema::InputObject.new(ruby_kwargs: arguments[:input], context: query_ctx, defaults_used: nil)
else
args = arguments
end
field.resolve(parent, args, query_ctx)
#------------------------------------------------------------------------------
# arguments = field.to_graphql.arguments_class.new(
# GraphqlHelpers.deep_fieldnamerize(args),
# context: query_ctx,
# defaults_used: []
# )
# arguments[:input] = GraphQL::Schema::InputObject.new(ruby_kwargs: arguments[:input].to_h, context: query_ctx, defaults_used: nil) if field.resolver && field.resolver <= ::Mutations::BaseMutation
# field.resolve(parent, arguments.to_h, query_ctx)
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment