refactor: update graphql

This commit is contained in:
Qiuxia Fan 2022-02-07 15:33:52 +08:00
parent 4b194a18f8
commit a994a76ede
12 changed files with 15 additions and 13 deletions

View File

@ -17,7 +17,7 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import { LayoutConfig } from "@/types/dashboard";
import graph from "@/graph";
import graphql from "@/graphql";
import { ConfigData, ConfigData1, ConfigData2, ConfigData3 } from "../data";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
@ -186,14 +186,14 @@ export const dashboardStore = defineStore({
this.selectedGrid = this.layout[index];
},
async fetchMetricType(item: string) {
const res: AxiosResponse = await graph
const res: AxiosResponse = await graphql
.query("queryTypeOfMetrics")
.params({ name: item });
return res.data;
},
async fetchMetricList(regex: string) {
const res: AxiosResponse = await graph
const res: AxiosResponse = await graphql
.query("queryMetrics")
.params({ regex });

View File

@ -18,7 +18,7 @@ import { defineStore } from "pinia";
import { Duration } from "@/types/app";
import { Service, Instance, Endpoint } from "@/types/selector";
import { store } from "@/store";
import graph from "@/graph";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app";
@ -51,12 +51,12 @@ export const selectorStore = defineStore({
this.currentPod = pod;
},
async fetchLayers(): Promise<AxiosResponse> {
const res: AxiosResponse = await graph.query("queryLayers").params({});
const res: AxiosResponse = await graphql.query("queryLayers").params({});
return res.data || {};
},
async fetchServices(layer: string): Promise<AxiosResponse> {
const res: AxiosResponse = await graph
const res: AxiosResponse = await graphql
.query("queryServices")
.params({ layer });
@ -72,7 +72,7 @@ export const selectorStore = defineStore({
if (!serviceId) {
return null;
}
const res: AxiosResponse = await graph.query("queryInstances").params({
const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId,
duration: this.durationTime,
});
@ -95,7 +95,7 @@ export const selectorStore = defineStore({
if (!serviceId) {
return null;
}
const res: AxiosResponse = await graph.query("queryEndpoints").params({
const res: AxiosResponse = await graphql.query("queryEndpoints").params({
serviceId,
duration: this.durationTime,
keyword: params.keyword,
@ -109,7 +109,7 @@ export const selectorStore = defineStore({
if (!serviceId) {
return;
}
const res: AxiosResponse = await graph.query("queryService").params({
const res: AxiosResponse = await graphql.query("queryService").params({
serviceId,
});
if (!res.data.errors) {
@ -123,7 +123,7 @@ export const selectorStore = defineStore({
if (!instanceId) {
return;
}
const res: AxiosResponse = await graph.query("queryInstance").params({
const res: AxiosResponse = await graphql.query("queryInstance").params({
instanceId,
});
if (!res.data.errors) {
@ -136,7 +136,7 @@ export const selectorStore = defineStore({
if (!endpointId) {
return;
}
const res: AxiosResponse = await graph.query("queryEndpoint").params({
const res: AxiosResponse = await graphql.query("queryEndpoint").params({
endpointId,
});
if (!res.data.errors) {

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import graph from "@/graph";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
const getLocalTime = (utc: string, time: Date): Date => {
@ -38,7 +38,9 @@ const setTimezoneOffset = () => {
export const queryOAPTimeInfo = async (): Promise<void> => {
let utc = window.localStorage.getItem("utc");
if (!utc) {
const res: AxiosResponse = await graph.query("queryOAPTimeInfo").params({});
const res: AxiosResponse = await graphql
.query("queryOAPTimeInfo")
.params({});
if (
!res.data ||
!res.data.data ||