This commit is contained in:
Fine 2025-04-21 22:21:31 +08:00
parent c5c34f5b6a
commit 55ac094fc4
3 changed files with 8 additions and 4 deletions

View File

@ -17,6 +17,12 @@
* under the License.
*/
type GraphQLErrors = Array<{ message: string }>;
type GraphQLResponse<T> = {
data?: T;
errors?: GraphQLErrors;
};
export let globalAbortController = new AbortController();
export function abortRequestsAndUpdate() {
globalAbortController.abort();

View File

@ -14,14 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { cancelToken } from "@/utils/cancelToken";
import { httpQuery } from "./base";
async function fetchQuery(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
const response = await httpQuery({
method: "post",
json: { query: param.queryStr, variables: { ...param.conditions } },
headers: { cancelToken: cancelToken() },
headers: {},
});
if (response.errors) {
response.errors = response.errors.map((e: { message: string }) => e.message).join(" ");

View File

@ -15,7 +15,6 @@
* limitations under the License.
*/
import { httpQuery } from "./base";
import { cancelToken } from "@/utils/cancelToken";
import * as app from "./query/app";
import * as selector from "./query/selector";
import * as dashboard from "./query/dashboard";
@ -52,7 +51,7 @@ class Graphql {
public params(variables: unknown) {
return httpQuery({
method: "post",
headers: { cancelToken: cancelToken() },
headers: {},
json: {
query: query[this.queryData],
variables,