kpsquery
v0.1.9
Published
KPS 是我专门为 KPS 从后台获取数据专门设计的 getter.
Downloads
9
Readme
KPS Query Lib
KPS 是我专门为 KPS 从后台获取数据专门设计的 getter.
安装方式
npm install kpsquery --save-dev
调用方式
KPS 接口
const KPS = kpsquery.create({ url: 'http://localhost:8000/kpsquery' })
KPS({
data: {
query: `query($str:String){
someTaskGeneral(first:20,name_Icontains:$str){
edges{
node{
name
startTime
dueTime
taskactionSet{
edges{
node{
name
id
startTime
dueTime
entityType
owner{
edges{
node{
username
}
}
}
parentTask{
name
originalId
}
}
}
}
owner{
edges{
node{
username
id
isStaff
}
}
}
}
}
}
}`,
variables: {
str: 'task'
}
}
}).then(res => {
console.log('res :', res)
})
返回值是
{
"data": {
"data": {
"someTaskGeneral": {
"edges": [
{
"node": {
"name": "task1",
"startTime": "2019-10-24T05:25:02.368942+00:00",
"dueTime": "2019-11-24T13:26:37.588000+00:00",
"taskactionSet": {
"edges": [
{
"node": {
"name": "taskaction7",
"id": "VGFza0FjdGlvbk5vZGU6NA==",
"startTime": "2019-10-24T05:52:28.735027+00:00",
"dueTime": "2019-11-27T13:54:56.363000+00:00",
"entityType": "TaskAction",
"owner": {
"edges": []
},
"parentTask": {
"name": "task1",
"originalId": 1
}
}
},
{
"node": {
"name": "taskaction1",
"id": "VGFza0FjdGlvbk5vZGU6Mw==",
"startTime": "2019-10-24T05:51:35.517135+00:00",
"dueTime": "2019-11-24T13:55:06.036000+00:00",
"entityType": "TaskAction",
"owner": {
"edges": []
},
"parentTask": {
"name": "task1",
"originalId": 1
}
}
},
{
"node": {
"name": "taskaction1",
"id": "VGFza0FjdGlvbk5vZGU6Mg==",
"startTime": "2019-10-24T05:51:16.377093+00:00",
"dueTime": "2019-10-24T13:55:12.667000+00:00",
"entityType": "TaskAction",
"owner": {
"edges": []
},
"parentTask": {
"name": "task1",
"originalId": 1
}
}
}
]
},
"owner": {
"edges": []
}
}
},
{
"node": {
"name": "task2",
"startTime": "2019-10-24T05:25:02.368942+00:00",
"dueTime": "2019-11-24T13:26:37.588000+00:00",
"taskactionSet": {
"edges": []
},
"owner": {
"edges": []
}
}
}
]
}
}
},
"status": 200,
"statusText": "OK",
"headers": {
"content-type": "application/json"
},
"config": {
"data": "{\"query\":\"query($str:String){\\n someTaskGeneral(first:20,name_Icontains:$str){\\n edges{\\n node{\\n name\\n startTime\\n dueTime\\n taskactionSet{\\n edges{\\n node{\\n name\\n id\\n startTime\\n dueTime\\n entityType\\n owner{\\n edges{\\n node{\\n username\\n }\\n }\\n }\\n parentTask{\\n name\\n originalId\\n }\\n }\\n }\\n }\\n owner{\\n edges{\\n node{\\n username\\n id\\n isStaff\\n }\\n }\\n }\\n }\\n }\\n }\\n }\",\"variables\":{\"str\":\"task\"}}",
"url": "http://localhost:8000/kpsquery",
"method": "post",
"timeout": 0,
"headers": {
"Accept": "application/json,text/plain,*/*",
"Content-Type": "application/json;charset=utf-8"
},
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "x-XSRF-TOKEN",
"transformRequest": [null],
"transformResponse": [null]
},
"request": {}
}