GraphQL
GraphQL
basis
See Getting Started with GraphQL Java and Spring Boot
You can install graphQL for MAC client using brew install –cask GraphQL-playground.
IDEA
How to debugGraphQL
application
The installationJS GraphQL
The plug-in
Click JS GraphQL to install the plug-in
GraphQL
define
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
}
Copy the code
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}}}}Copy the code
Create a query file
query.graphql
# {"id": "book-1"}
query queryData($id: ID) {
bookById(id: $id) {
id name pageCount author {
id firstName lastName
}
}
}
Copy the code
GraphQL
Script directory structure
Resources ├ ─ ─ graphqlconfig# config file├ ─ ─ query. Graphql# query file└ ─ ─ schema. Graphqls# define file
Copy the code
The execution result
GraphQL
在 Skywalking
The application of
Graphql agreement file path: oap – server/server – query – the plugin/query – graphql – the 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}}}}Copy the code
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 }} } }Copy the code
The execution result
{
"data": {
"readMetricsValues": {
"values": {
"values": [{"id": "202107031400_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM="."value": 22
},
{
"id": "202107031401_YnVzaW5lc3Mtem9uZTo6cHJvamVjdEE=.1_ZThjZjM0YTFkNTRhNDA1OGE4Yzk4NTA1ODc3NzcwZTJAMTkyLjE2OC41MC4xMTM="."value": 22}]}}}}Copy the code
Reference documentation
- Query Protocol
- GraphQL website
- Getting started with GraphQL Java and Spring Boot
- graphql-java/tutorials/book-details
- graphql-playground
- JS GraphQL
Share and record what you learn and see