Skip to content

Commit

Permalink
feat: Update create_case mutation to include auto-
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Jan 23, 2024
1 parent 513b931 commit 84946ea
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions backend/graphql/mutations/create_case.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module Mutations
class CreateCase < BaseMutation
argument :name, String, required: true
argument :status_id, ID, required: true
argument :priority_id, ID, required: true
argument :created_by_id, ID, required: true
argument :assigned_to_id, ID, required: false
argument :description, String, required: false

field :case, Types::CaseType, null: true
field :errors, [String], null: false

def resolve(name:, status_id:, priority_id:, created_by_id:, assigned_to_id: nil, description: nil)
new_case = Case.new(
name: name,
status_id: status_id,
priority_id: priority_id,
created_by_id: created_by_id,
assigned_to_id: assigned_to_id,
description: description
)

if new_case.save
{ case: new_case, errors: [] }
else
{ case: nil, errors: new_case.errors.full_messages }
end
end
end
end

0 comments on commit 84946ea

Please sign in to comment.