Conversation
831722b to
9f0d8af
Compare
50639d4 to
f974793
Compare
deepsidhu85
left a comment
There was a problem hiding this comment.
Still need to test this out but just have a few comments to start
There was a problem hiding this comment.
Just leaving my initial review here as it suggests some drastic changes, basically I think the status field should be more like the status from updateSampleMetadata e.g.
updateSampleMetadata:
"status": {
"added": [],
"updated": [],
"deleted": [],
"not_updated": [],
"unchanged": [
"new_metadata_1",
"new_metadata_2"
]
},suggested bulkUpdateSampleMedata:
"status": {
"INXT_SAM_A2ENQXTKLT": {
"added": [],
"updated": [],
"deleted": [],
"not_updated": [],
"unchanged": [
"new_metadata_1",
"new_metadata_2"
]
},
...
},This way a tool using the API has a clearer idea of what changes have been persisted, which is easier then parsing a status message string. This would also mean that it should not have any errors present, errors should only occur when sample could not be located, or permissions prevent update.
The mutation has been updated to return the full list of |
deepsidhu85
left a comment
There was a problem hiding this comment.
Just a few more comments below
| field :errors, [Types::UserErrorType], description: 'A list of errors that prevented the mutation.' | ||
| field :overall_status, GraphQL::Types::String, null: true, | ||
| description: 'Overall description of mutation after completion' | ||
| field :status, GraphQL::Types::JSON, null: true, description: 'The status of the mutation.' |
There was a problem hiding this comment.
Lets update this description to The status of the mutation which lists the fields which were added, removed, updated, and unchanged
There was a problem hiding this comment.
Updated in 5a92e1c
added not_found as that will be added in a follow up commit as discussed
| def resolve(args) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity | ||
| namespace = retrieve_namespace(args) | ||
|
|
||
| if namespace.nil? |
There was a problem hiding this comment.
Move the code in this block into it's own method and then here we can just do a return METHOD_NAME. The 2 blocks of code below it which also return the user errors, can be updated in a similar fashion
There was a problem hiding this comment.
Thanks, I cleaned up basically anywhere that called the return hash, and made that into its own method with kwargs where we can default to nil values since most return values will be nil
5a92e1c
… bulk update mutation
…unchanged metadata test
…atus; fix associated tests
…etadata value when field doesn't exist
0e7475e to
2b90f6e
Compare
JeffreyThiessen
left a comment
There was a problem hiding this comment.
Looks good overall. Just one small nitpick on making the code slightly more readable.
| def parse_gid(sample_identifier) | ||
| IridaSchema.parse_gid(sample_identifier, { expected_type: Sample }).model_id | ||
| rescue StandardError => e | ||
| Rails.logger.error "An error occurred: #{e.message}" |
There was a problem hiding this comment.
Please update this error message to something a bit more descriptive of the error that is occurring, such as: "An error occurred while attempting to parse Sample gid with following message: #{e.message]"
There was a problem hiding this comment.
Also, I think we should explicitly return nil in the error case (or its expected that nil is returned from the Rails.logger.error return, add a comment specifying that). When trying to trace the error case through the code I was unsure of how this would behave if this occurred from the original find_sample call.
What does this PR do and why?
This PR is part 2 of 2 for STRY0019725 and creates the new
BulkUpdateSampleMetadatamutation that now accepts multiple sample inputs and uses the newmetadata/bulk_update_service. This will allow users to update multiple samples within a namespace at once.Mutation example:
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other pull requests.
How to set up and validate locally
Access the API through
http://localhost:3000/graphiqland test the following cases using multiple samples at once:project_puid,project_gid,group_puid, andgroup_gid.name,gid, andpuidas identifiers. Note: use stringified JSON if the identifier has special characters that need to be escapedPR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.