$headers = @{
|
"Content-Type" = "application/json"
|
}
|
|
# 测试1: 创建简单比赛(不包含评委)
|
$body1 = @{
|
query = 'mutation { saveActivity(input: { name: "Test Competition", description: "Test Description", signupDeadline: "2024-12-31T23:59:59", ratingSchemeId: 1, pid: 0 }) { id name description pid } }'
|
} | ConvertTo-Json
|
|
Write-Host "创建简单比赛测试..."
|
$response1 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body1 -Headers $headers
|
Write-Host "响应结果:"
|
$response1 | ConvertTo-Json -Depth 10
|
|
if ($response1.data -and $response1.data.saveActivity) {
|
$competitionId = $response1.data.saveActivity.id
|
Write-Host "比赛创建成功,ID: $competitionId"
|
|
# 测试2: 读取创建的比赛
|
$body2 = @{
|
query = "query { activity(id: $competitionId) { id name description pid } }"
|
} | ConvertTo-Json
|
|
Write-Host "读取比赛测试..."
|
$response2 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body2 -Headers $headers
|
Write-Host "读取结果:"
|
$response2 | ConvertTo-Json -Depth 10
|
} else {
|
Write-Host "比赛创建失败"
|
}
|