From 84b2a3dae7b407b9c4ec33daef612a7b2bb1866f Mon Sep 17 00:00:00 2001 From: Emma Lejeck Date: Sun, 21 Apr 2024 20:23:42 -0700 Subject: [PATCH] Fix FancyMutation logic for GraphQL 2.x --- app/graphql/concerns/fancy_mutation.rb | 8 ++++---- spec/graphql/concerns/fancy_mutation_spec.rb | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/graphql/concerns/fancy_mutation.rb b/app/graphql/concerns/fancy_mutation.rb index 6aa55f6f8..311ab702a 100644 --- a/app/graphql/concerns/fancy_mutation.rb +++ b/app/graphql/concerns/fancy_mutation.rb @@ -79,21 +79,21 @@ def resolve(input:, ignore_warnings: false) # mutation's #ready? and #authorized? methods, detecting the state of the error object after # execution and changing the result if needed. def ready?(input:) - ready, result = super(**input) + result = super(**input) return [false, { errors: }] if errors.present? - [ready, result] + result rescue ErrorWrapper => e [false, { errors: [*errors, e.error] }] end def authorized?(input:) - ready, result = super(**input) + result = super(**input) return [false, { errors: }] if errors.present? - [ready, result] + result rescue ErrorWrapper => e [false, { errors: [*errors, e.error] }] end diff --git a/spec/graphql/concerns/fancy_mutation_spec.rb b/spec/graphql/concerns/fancy_mutation_spec.rb index fabaf61fb..87972acd3 100644 --- a/spec/graphql/concerns/fancy_mutation_spec.rb +++ b/spec/graphql/concerns/fancy_mutation_spec.rb @@ -16,12 +16,12 @@ include FancyMutation def ready?(**) - [true, 'test'] + true end end result = mutation.new.ready?(input: {}) - expect(result).to eq([true, 'test']) + expect(result).to be(true) end end