-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Port Hardware Type to Ash #433
Port Hardware Type to Ash #433
Conversation
ff33d05
to
4eb03a2
Compare
2dcb63f
to
727dc6b
Compare
bbccaa7
to
b9bfa39
Compare
|
||
mutations do | ||
create :create_hardware_type, :create | ||
update :update_hardware_type, :update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateHardwareType(
id: ID
input: UpdateHardwareTypeInput
): UpdateHardwareTypeResult
Same here, ID
and input
should be non-nullable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above
default_document = """ | ||
mutation DeleteHardwareType($id: ID!) { | ||
deleteHardwareType(id: $id) { | ||
result { | ||
id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Querying partNumbers
of deleted HardwareType (add next fields after id
)
partNumbers {
partNumber
}
returns null
in result
with
errors: [
%{
message: "Cannot return null for non-nullable field",
path: ["deleteHardwareType", "result", "partNumbers", 0, "partNumber"],
locations: [%{line: 6, column: 9}]
}
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, move to ash-porting
issue
|
||
assert {:ok, %HardwareType{name: ^initial_name, handle: ^initial_handle}} = | ||
Devices.fetch_hardware_type(hardware_type.id) | ||
test "returns error for empty part_numbers", %{tenant: tenant, hardware_type: hardware_type} do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also check for invalid part_number
like
test "returns error for invalid part_number", %{tenant: tenant, hardware_type: hardware_type} do
result =
update_hardware_type_mutation(
tenant: tenant,
id: hardware_type.id,
part_numbers: [""]
)
assert %{"fields" => ["part_number"], "message" => "is required"} =
extract_error!(result)
end
But we have no partNumber
input field, not sure how to return this error better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, move to ash-porting
issue
|
||
alias Edgehog.Devices.HardwareType | ||
graphql do | ||
type :hardware_type_part_number |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type HardwareTypePartNumber {
id: ID!
"The part number identifier."
partNumber: String!
hardwareType: HardwareType
}
Should hardwareType
field be non-nullable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've checked and currently hardware_type_id
is actually nullable at the DB level (see here), so this is coherent with the status-quo.
The goal of the first step of the migration is having the resources reflect the current state of the database, then we can start adjusting the constraint with subsequent migrations.
name | ||
handle | ||
partNumbers { | ||
partNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having option to query hardwareType
field on HardwareTypePartNumber
type, do we want to test nested queries? like
partNumbers {
partNumber
hardwareType {
name
handle
partNumbers {
partNumber
hardwareType {
name
handle
}
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll re-evaluate filters and sorts at the end of the porting process, please open a generic issue about this with the ash-porting
label so that we have an item tracking this
b9bfa39
to
40049f3
Compare
This will be handled by AshGraphql now. Add a TODO to error.ex since it's not possible to remove it now. Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
15eb0b0
to
26a46ef
Compare
Makes results nullable when using root level errors (see ash-project/ash_graphql#114) Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
Expose its queries and mutations via AshGraphql Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
They map more naturally with the error handling we were currently using. We could possibly evaluate reverting this in a second phase. Signed-off-by: Riccardo Binetti <riccardo.binetti@secomind.com>
26a46ef
to
beeedfc
Compare
00f17db
into
edgehog-device-manager:from-ash-we-rise
Add all the relevant tests in the Graphql part and remove unused old code