| | |
| | | import { JUDGE_QUERIES, JUDGE_MUTATIONS } from './graphql' |
| | | import type { Judge, JudgeInput, CosCredentials, Tag, Media } from './graphql' |
| | | |
| | | const GRAPHQL_ENDPOINT = 'http://localhost:8080/api/graphql' |
| | | import { API_CONFIG, graphqlRequest } from '@/config/api' |
| | | |
| | | // GraphQL请求函数 |
| | | async function graphqlRequest(query: string, variables: any = {}) { |
| | | const response = await fetch(GRAPHQL_ENDPOINT, { |
| | | method: 'POST', |
| | | headers: { |
| | | 'Content-Type': 'application/json', |
| | | }, |
| | | body: JSON.stringify({ |
| | | query, |
| | | variables, |
| | | }), |
| | | }) |
| | | |
| | | if (!response.ok) { |
| | | throw new Error(`HTTP error! status: ${response.status}`) |
| | | } |
| | | |
| | | const result = await response.json() |
| | | |
| | | if (result.errors) { |
| | | throw new Error(result.errors[0]?.message || 'GraphQL error') |
| | | } |
| | | |
| | | return result.data |
| | | } |
| | | // 使用统一的GraphQL请求函数 |
| | | |
| | | export class JudgeApi { |
| | | // 获取所有评委 |