Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions api/generated-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1192,11 +1192,6 @@ type ArrayMutations {
"""Add new disk to array"""
addDiskToArray(input: ArrayDiskInput!): UnraidArray!

"""
Remove existing disk from array. NOTE: The array must be stopped before running this otherwise it'll throw an error.
"""
removeDiskFromArray(input: ArrayDiskInput!): UnraidArray!

"""Mount a disk in the array"""
Comment on lines 1192 to 1195

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Regenerate the web schema types after removing the field

web/codegen.ts consumes this schema, but the checked-in web/src/composables/gql/graphql.ts still exposes ArrayMutations.removeDiskFromArray and its argument type. The resulting client types falsely advertise a mutation the server now rejects, so web code can type-check against an unavailable API; regenerate and commit the web GraphQL output alongside this schema change.

AGENTS.md reference: AGENTS.md:L115-L120

Useful? React with 👍 / 👎.

mountArrayDisk(id: PrefixedID!): ArrayDisk!

Expand Down
7 changes: 0 additions & 7 deletions api/src/unraid-api/cli/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ export type ArrayMutations = {
clearArrayDiskStatistics: Scalars['Boolean']['output'];
/** Mount a disk in the array */
mountArrayDisk: ArrayDisk;
/** Remove existing disk from array. NOTE: The array must be stopped before running this otherwise it'll throw an error. */
removeDiskFromArray: UnraidArray;
/** Set array state */
setState: UnraidArray;
/** Unmount a disk from the array */
Expand All @@ -337,11 +335,6 @@ export type ArrayMutationsMountArrayDiskArgs = {
};


export type ArrayMutationsRemoveDiskFromArrayArgs = {
input: ArrayDiskInput;
};


export type ArrayMutationsSetStateArgs = {
input: ArrayStateInput;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ export class ArrayMutationsResolver {
return this.arrayService.addDiskToArray(input);
}

@ResolveField(() => UnraidArray, {
description:
"Remove existing disk from array. NOTE: The array must be stopped before running this otherwise it'll throw an error.",
})
@UsePermissions({
action: AuthAction.UPDATE_ANY,
resource: Resource.ARRAY,
})
public async removeDiskFromArray(@Args('input') input: ArrayDiskInput): Promise<UnraidArray> {
return this.arrayService.removeDiskFromArray(input);
}

@ResolveField(() => ArrayDisk, { description: 'Mount a disk in the array' })
@UsePermissions({
action: AuthAction.UPDATE_ANY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('ArrayResolver', () => {
useValue: {
updateArrayState: vi.fn(),
addDiskToArray: vi.fn(),
removeDiskFromArray: vi.fn(),
mountArrayDisk: vi.fn(),
unmountArrayDisk: vi.fn(),
clearArrayDiskStatistics: vi.fn(),
Expand Down
20 changes: 0 additions & 20 deletions api/src/unraid-api/graph/resolvers/array/array.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,26 +305,6 @@ describe('ArrayService', () => {
});
});

describe('removeDiskFromArray', () => {
const input: ArrayDiskInput = { id: 'test-disk', slot: 1 };

it('should remove disk from array when STOPPED', async () => {
const result = await service.removeDiskFromArray(input);
expect(result).toEqual(mockArrayData);
expect(mockEmcmd).toHaveBeenCalledWith({
changeDevice: 'apply',
'slotId.1': '',
});
expect(mockGetArrayDataUtil).toHaveBeenCalledTimes(1);
});

it('should throw ArrayRunningError when array is STARTED', async () => {
mockEmhttp.mockReturnValue({ var: { mdState: ArrayState.STARTED } } as any);
await expect(service.removeDiskFromArray(input)).rejects.toThrow(new ArrayRunningError());
expect(mockEmcmd).not.toHaveBeenCalled();
});
});

describe('mountArrayDisk', () => {
const diskId = 'test-disk';

Expand Down
17 changes: 0 additions & 17 deletions api/src/unraid-api/graph/resolvers/array/array.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,6 @@ export class ArrayService {
return this.getArrayData();
}

async removeDiskFromArray(input: ArrayDiskInput): Promise<UnraidArray> {
if (await this.arrayIsRunning()) {
throw new ArrayRunningError();
}

const { slot } = input;
const slotStr = slot?.toString() ?? '';

// Remove disk
await emcmd({
changeDevice: 'apply',
[`slotId.${slotStr}`]: '',
});

return this.getArrayData();
}

async mountArrayDisk(id: string): Promise<UnraidArray> {
if (!(await this.arrayIsRunning())) {
throw new BadRequestException('Array must be running to mount disks');
Expand Down
Loading