import type { SetRequired } from 'type-fest'; import type { RequestResponse } from '../request.js'; import type { GraphqlError } from './error.js'; /** 响应错误信息 */ export interface GraphqlErrorData { /** 消息 */ message: string; } /** Graphql 错误 */ export interface GraphqlErrorLike extends Error { /** 原始请求 */ request: GraphqlRequest; } /** Graphql 响应 */ export interface GraphqlResponseData { /** 数据 */ data: T; /** 错误 */ errors?: GraphqlErrorData[]; /** 扩展信息 */ extensions: unknown; } /** Graphql 响应 */ export interface GraphqlResponse extends RequestResponse { /** 数据 */ data: T; /** 错误 */ errors?: GraphqlError[]; /** 扩展信息 */ extensions: unknown; /** 原始请求 */ request: GraphqlRequest; } /** Graphql 请求 */ export interface GraphqlRequestData { /** 请求 */ query: string; /** 变量 */ variables?: Record; /** 执行的查询名称 */ operationName?: string; } /** Graphql 请求 */ export interface GraphqlRequest extends SetRequired { /** url */ url: string; }