Skywalking-10: skywalking query protocol -- graphql

Switch 2021-10-14 05:46:54

GraphQL

GraphQL  Basics

reference Getting started with GraphQL Java and Spring Boot Just learn this article

PS: have access to brew install --cask graphql-playground  install graphql for mac  client .

IDEA  How to debug GraphQL  application

install JS GraphQL  plug-in unit

Click on JS GraphQL Installing a plug-in

GraphQL  Definition

schema.graphqls

type Query {
bookById(id: ID): Book
}
type Book {
id: ID
name: String
pageCount: Int
author: Author
}
type Author {
id: ID
firstName: String
lastName: String
}

GraphQL  The configuration file

.graphqlconfig

{
"name": "book-details",
"schemaPath": "schema.graphqls",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:8080/graphql", // Request path
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": false
}
}
}
}

Create a query file

query.graphql

# {"id": "book-1"}
query queryData($id: ID) {
bookById(id: $id) {
id name pageCount author {
id firstName lastName
}
}
}

GraphQL Script directory structure

resources
├── .graphqlconfig # The configuration file
├── query.graphql # Query file
└── schema.graphqls # The definition file 

Execution results

file

file

GraphQL  stay Skywalking  Application in

graphql  Protocol file path : oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol 

GraphQL The configuration file

.graphqlconfig

{
"name": "skywalking",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:8080/graphql",
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": true
}
}
}
}

Create a query file

query.graphql

query queryData {
readMetricsValues(
duration: {start: "2021-07-03 1400",end: "2021-07-03 1401", step: MINUTE},
condition: {
name: "instance_jvm_thread_runnable_thread_count",
entity: {
scope: ServiceInstance,
serviceName: "business-zone::projectA",
serviceInstanceName: "[email protected]",
normal: true
}
}
) {
label values{ values{ id value }}
}
}

Execution results

{
"data": {
"readMetricsValues": {
"values": {
"values": [
{
"id": "202107031400_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM=",
"value": 22
},
{
"id": "202107031401_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM=",
"value": 22
}
]
}
}
}
}

Reference documents

Please bring the original link to reprint ,thank
Similar articles

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14

2021-10-14