schema {
    query: Query
    mutation: Mutation
}

#Root node
type Query {
    version: String
}

type Mutation {
    version: String
}

# The Duration defines the start and end time for each query operation.
# Fields: `start` and `end`
#   represents the time span. And each of them matches the step.
#   ref https://www.ietf.org/rfc/rfc3339.txt
#   The time formats are
#       `SECOND` step: yyyy-MM-dd HHmmss
#       `MINUTE` step: yyyy-MM-dd HHmm
#       `HOUR` step: yyyy-MM-dd HH
#       `DAY` step: yyyy-MM-dd
#       `MONTH` step: yyyy-MM
# Field: `step`
#   represents the accurate time point.
# e.g.
#   if step==HOUR , start=2017-11-08 09, end=2017-11-08 19
#   then
#       metrics from the following time points expected
#       2017-11-08 9:00 -> 2017-11-08 19:00
#       there are 11 time points (hours) in the time span.
input Duration {
    start: String!
    end: String!
    step: Step!
}

enum Step {
    MONTH
    DAY
    HOUR
    MINUTE
    SECOND
}

input Pagination {
    # pageNum starts in 1, the default is 1.
    pageNum: Int
    pageSize: Int!
    # default false
    needTotal: Boolean
}

######################################
# Common Metrics and Trends
######################################
type ResponseTimeTrend {
    trendList: [Int!]
}

type ThroughputTrend {
    trendList: [Int!]!
}

type SLATrend {
    trendList: [Int!]!
}

# The overview topology of the whole application cluster or services,
type Topology {
    nodes: [Node!]!
    calls: [Call!]!
}

# The base Node of all node types in topology
interface Node {
    # The global id of each node,
    # 1. `Application ID` represents application under monitoring
    # 2. `Peer ID` string represents the conjectural dependency.
    id: ID!
    # Application Code or literal Peer
    name: String!
    # The type name
    # 1. The most important component in the application, from service provider perspective.
    # 2. Conjectural dependent component, e.g. MySQL, Redis, Kafka
    type: String
}

# Incoming request node, means User or outside system access the cluster from this.
type VisualUserNode implements Node {
    id: ID!
    # Constant, value = "User"
    name: String!
    # Constant, value = "USER"
    type: String
}

# The Call represents a directed distributed call,
# from the `source` to the `target`.
type Call {
    source: ID!
    target: ID!
    isAlert: Boolean
    # The protocol and tech stack used in this distributed call
    callType: String!
    callsPerSec: Long!
    # Unit: millisecond
    responseTimePerSec: Long!
}
