共计 1962 个字符,预计需要花费 5 分钟才能阅读完成。
GraphQL
GraphQL
根底
参照 Getting started with GraphQL Java and Spring Boot 这篇文章学习即可
PS:能够应用 brew install --cask graphql-playground
装置 graphql for mac
客户端。
IDEA
怎么调试 GraphQL
利用
装置 JS GraphQL
插件
点击 JS GraphQL 装置插件
GraphQL
定义
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
配置文件
.graphqlconfig
{
"name": "book-details",
"schemaPath": "schema.graphqls",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:8080/graphql", // 申请门路
"headers": {"user-agent": "JS GraphQL"},
"introspect": false
}
}
}
}
创立一个查问文件
query.graphql
# {"id": "book-1"}
query queryData($id: ID) {bookById(id: $id) {
id name pageCount author {id firstName lastName}
}
}
GraphQL
脚本目录构造
resources
├── .graphqlconfig # 配置文件
├── query.graphql # 查问文件
└── schema.graphqls # 定义文件
执行后果
GraphQL
在 Skywalking
中的利用
graphql
协定文件门路:oap-server/server-query-plugin/query-graphql-plugin/src/main/resources/query-protocol
GraphQL
配置文件
.graphqlconfig
{
"name": "skywalking",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:8080/graphql",
"headers": {"user-agent": "JS GraphQL"},
"introspect": true
}
}
}
}
创立一个查问文件
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: "e8cf34a1d54a4058a8c98505877770e2@192.168.50.113",
normal: true
}
}
) {label values{ values{ id value}}
}
}
执行后果
{
"data": {
"readMetricsValues": {
"values": {
"values": [
{
"id": "202107031400_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM=",
"value": 22
},
{
"id": "202107031401_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM=",
"value": 22
}
]
}
}
}
}
参考文档
- Query Protocol
- GraphQL 官网
- Getting started with GraphQL Java and Spring Boot
- graphql-java/tutorials/book-details
- graphql-playground
-
JS GraphQL
分享并记录所学所见
正文完