Skip to content

Commit

Permalink
Use CleanBaseMutation
Browse files Browse the repository at this point in the history
  • Loading branch information
martha committed Feb 6, 2025
1 parent b1acea3 commit 7f32663
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
2 changes: 1 addition & 1 deletion drivers/hmis/app/graphql/mutations/split_household.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
###

module Mutations
class SplitHousehold < BaseMutation
class SplitHousehold < CleanBaseMutation
argument :splitting_enrollment_inputs, [Types::HmisSchema::EnrollmentRelationshipInput], required: true

field :new_household, Types::HmisSchema::Household, null: false
Expand Down
22 changes: 1 addition & 21 deletions drivers/hmis/app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6252,12 +6252,7 @@ type Mutation {
"""
input: SaveAssessmentInput!
): SaveAssessmentPayload
splitHousehold(
"""
Parameters for SplitHousehold
"""
input: SplitHouseholdInput!
): SplitHouseholdPayload
splitHousehold(splittingEnrollmentInputs: [EnrollmentRelationshipInput!]!): SplitHouseholdPayload

"""
Create/Submit assessment, and create/update related HUD records
Expand Down Expand Up @@ -11185,25 +11180,10 @@ enum SexualOrientation {
QUESTIONING_UNSURE
}

"""
Autogenerated input type of SplitHousehold
"""
input SplitHouseholdInput {
"""
A unique identifier for the client performing the mutation.
"""
clientMutationId: String
splittingEnrollmentInputs: [EnrollmentRelationshipInput!]!
}

"""
Autogenerated return type of SplitHousehold.
"""
type SplitHouseholdPayload {
"""
A unique identifier for the client performing the mutation.
"""
clientMutationId: String
errors: [ValidationError!]!
newHousehold: Household!
remainingHousehold: Household!
Expand Down
18 changes: 8 additions & 10 deletions drivers/hmis/spec/requests/hmis/split_household_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

let(:mutation) do
<<~GRAPHQL
mutation SplitHousehold($input: SplitHouseholdInput!) {
splitHousehold(input: $input) {
mutation SplitHousehold($splittingEnrollmentInputs: [EnrollmentRelationshipInput!]!) {
splitHousehold(splittingEnrollmentInputs: $splittingEnrollmentInputs) {
newHousehold {
id
householdSize
Expand Down Expand Up @@ -63,9 +63,7 @@ def perform_mutation(
]
)
input = {
input: {
splitting_enrollment_inputs: splitting_enrollment_inputs,
},
splitting_enrollment_inputs: splitting_enrollment_inputs,
}
response, result = post_graphql(input) { mutation }

Expand Down Expand Up @@ -113,7 +111,7 @@ def perform_mutation(
},
],
}
expect_access_denied post_graphql(input: input) { mutation }
expect_access_denied post_graphql(input) { mutation }
end

it 'fails when the given enrollment IDs are invalid' do
Expand All @@ -125,7 +123,7 @@ def perform_mutation(
},
],
}
expect_access_denied post_graphql(input: input) { mutation }
expect_access_denied post_graphql(input) { mutation }
end

context 'when the given enrollment IDs come from different households' do
Expand All @@ -144,7 +142,7 @@ def perform_mutation(
},
],
}
expect_gql_error post_graphql(input: input) { mutation }
expect_gql_error post_graphql(input) { mutation }
end
end

Expand All @@ -165,7 +163,7 @@ def perform_mutation(
},
],
}
expect_gql_error post_graphql(input: input) { mutation }, message: /Splitting all clients to a new household is invalid/
expect_gql_error post_graphql(input) { mutation }, message: /Splitting all clients to a new household is invalid/
end

it 'fails when the split would leave behind a headless household' do
Expand All @@ -177,6 +175,6 @@ def perform_mutation(
},
],
}
expect_gql_error post_graphql(input: input) { mutation }, message: /This operation would leave behind a household with no HoH, which is not allowed/
expect_gql_error post_graphql(input) { mutation }, message: /This operation would leave behind a household with no HoH, which is not allowed/
end
end

0 comments on commit 7f32663

Please sign in to comment.