fix: confusing server -> status query (#1635)

represent the target server's status instead of whether it's connected to Mothership.

Resolves #1627

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- Bug Fixes
- Ensures the local server is handled consistently as a single server
across views; list views show it as a single-item list when applicable.
  - Server status now reliably displays as Online for the local server.

- Documentation
- Added a clearer description for the server status field in the API
schema to improve tooltips and autogenerated docs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Pujit Mehrotra
2025-08-28 16:31:47 -04:00
committed by GitHub
parent 26a95af953
commit 9d42b36f74
2 changed files with 18 additions and 21 deletions

View File

@@ -38,7 +38,9 @@ export class Server extends Node {
@Field()
name!: string;
@Field(() => ServerStatus)
@Field(() => ServerStatus, {
description: 'Whether this server is online or offline',
})
status!: ServerStatus;
@Field()

View File

@@ -24,7 +24,7 @@ export class ServerResolver {
resource: Resource.SERVERS,
})
public async server(): Promise<ServerModel | null> {
return this.getLocalServer()[0] || null;
return this.getLocalServer() || null;
}
@Query(() => [ServerModel])
@@ -33,7 +33,7 @@ export class ServerResolver {
resource: Resource.SERVERS,
})
public async servers(): Promise<ServerModel[]> {
return this.getLocalServer();
return [this.getLocalServer()];
}
@Subscription(() => ServerModel)
@@ -45,7 +45,7 @@ export class ServerResolver {
return createSubscription(PUBSUB_CHANNEL.SERVERS);
}
private getLocalServer(): ServerModel[] {
private getLocalServer(): ServerModel {
const emhttp = getters.emhttp();
const connectConfig = this.configService.get('connect');
@@ -64,22 +64,17 @@ export class ServerResolver {
avatar: '',
};
return [
{
id: 'local',
owner,
guid: guid || '',
apikey: connectConfig?.config?.apikey ?? '',
name: name ?? 'Local Server',
status:
connectConfig?.mothership?.status === MinigraphStatus.CONNECTED
? ServerStatus.ONLINE
: ServerStatus.OFFLINE,
wanip,
lanip,
localurl,
remoteurl,
},
];
return {
id: 'local',
owner,
guid: guid || '',
apikey: connectConfig?.config?.apikey ?? '',
name: name ?? 'Local Server',
status: ServerStatus.ONLINE,
wanip,
lanip,
localurl,
remoteurl,
};
}
}