From c92ecc7dea7fad25e58c6b81616dbf660e099b48 Mon Sep 17 00:00:00 2001 From: Caio Almeida <117518+caiosba@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:07:50 -0300 Subject: [PATCH] Raise error when trying to save a null object Raise error when trying to save a null object through GraphQL update mutation. Reference: CV2-3826. --- app/graph/mutations/graphql_crud_operations.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/graph/mutations/graphql_crud_operations.rb b/app/graph/mutations/graphql_crud_operations.rb index 8b7a493136..15fe74f699 100644 --- a/app/graph/mutations/graphql_crud_operations.rb +++ b/app/graph/mutations/graphql_crud_operations.rb @@ -1,5 +1,6 @@ class GraphqlCrudOperations def self.safe_save(obj, attrs, parent_names = []) + raise "Can't save a null object." if obj.nil? raise 'This operation must be done by a signed-in user' if User.current.nil? && ApiKey.current.nil? attrs.each do |key, value| method = key == "clientMutationId" ? "client_mutation_id=" : "#{key}="