Skip to content
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

synce gm path added #393

Merged
merged 1 commit into from
Jan 26, 2024
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
35 changes: 35 additions & 0 deletions src/__generated__/topology-discovery.graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/external-api/topology-discovery-graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
UpdateCoordinatesMutation,
UpdateCoordinatesMutationVariables,
SynceTopologyQuery,
SyncePathToGrandMasterQuery,
SyncePathToGrandMasterQueryVariables,
} from '../__generated__/topology-discovery.graphql';
import {
HasAndInterfacesOutput,
Expand Down Expand Up @@ -355,6 +357,14 @@ const SYNCE_TOPOLOGY = gql`
}
`;

const SYNCE_PATH = gql`
query SyncePathToGrandMaster($deviceFrom: ID!) {
syncePathToGm(deviceFrom: $deviceFrom) {
nodes
}
}
`;

function getTopologyDiscoveryApi() {
if (!config.topologyEnabled) {
return undefined;
Expand Down Expand Up @@ -466,6 +476,17 @@ function getTopologyDiscoveryApi() {
return response;
}

async function getSyncePathToGrandMaster(deviceFrom: string): Promise<string[] | null> {
const response = await client.request<SyncePathToGrandMasterQuery, SyncePathToGrandMasterQueryVariables>(
SYNCE_PATH,
{
deviceFrom,
},
);

return response.syncePathToGm.nodes;
}

return {
getTopologyDevices,
getNetTopologyDevices,
Expand All @@ -479,6 +500,7 @@ function getTopologyDiscoveryApi() {
getPtpPathToGrandMaster,
updateCoordinates,
getSynceTopology,
getSyncePathToGrandMaster,
};
}

Expand Down
1 change: 1 addition & 0 deletions src/schema/api.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ type Query {
ptpPathToGrandMaster(deviceFrom: String!): [String!]
ptpTopology: PtpTopology
shortestPath(from: String!, to: String!): [NetRoutingPathNode!]!
syncePathToGrandMaster(deviceFrom: String!): [String!]
synceTopology: SynceTopology
topology(filter: FilterTopologyInput): Topology
topologyCommonNodes(nodes: [String!]!): TopologyCommonNodes
Expand Down
6 changes: 6 additions & 0 deletions src/schema/nexus-typegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,7 @@ export interface NexusGenFieldTypes {
ptpPathToGrandMaster: string[] | null; // [String!]
ptpTopology: NexusGenRootTypes['PtpTopology'] | null; // PtpTopology
shortestPath: NexusGenRootTypes['NetRoutingPathNode'][]; // [NetRoutingPathNode!]!
syncePathToGrandMaster: string[] | null; // [String!]
synceTopology: NexusGenRootTypes['SynceTopology'] | null; // SynceTopology
topology: NexusGenRootTypes['Topology'] | null; // Topology
topologyCommonNodes: NexusGenRootTypes['TopologyCommonNodes'] | null; // TopologyCommonNodes
Expand Down Expand Up @@ -1486,6 +1487,7 @@ export interface NexusGenFieldTypeNames {
ptpPathToGrandMaster: 'String';
ptpTopology: 'PtpTopology';
shortestPath: 'NetRoutingPathNode';
syncePathToGrandMaster: 'String';
synceTopology: 'SynceTopology';
topology: 'Topology';
topologyCommonNodes: 'TopologyCommonNodes';
Expand Down Expand Up @@ -1811,6 +1813,10 @@ export interface NexusGenArgTypes {
from: string; // String!
to: string; // String!
};
syncePathToGrandMaster: {
// args
deviceFrom: string; // String!
};
topology: {
// args
filter?: NexusGenInputs['FilterTopologyInput'] | null; // FilterTopologyInput
Expand Down
14 changes: 14 additions & 0 deletions src/schema/topology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,17 @@ export const SynceTopologyQuery = queryField('synceTopology', {
};
},
});

export const SyncePathToGrandMasterQuery = queryField('syncePathToGrandMaster', {
type: list(nonNull('String')),
args: {
deviceFrom: nonNull(stringArg()),
},
resolve: async (_, args, { topologyDiscoveryGraphQLAPI }) => {
const { deviceFrom } = args;
const fromNodeNativeId = fromGraphId('GraphNode', deviceFrom);

const syncePathResult = await topologyDiscoveryGraphQLAPI?.getSyncePathToGrandMaster(fromNodeNativeId);
return syncePathResult ?? [];
},
});