lrj
2 天以前 c61d4fe27c97d2ecc907756aa571a4ef14a7b9b6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
 
$headers = @{
    "Content-Type" = "application/json"
}
 
Write-Host "=== Debug Test ==="
 
# Test: Create competition with stages and check database
Write-Host "1. Creating competition with stages..."
$body1 = @{
    query = 'mutation { 
        saveActivity(input: { 
            name: "Debug Test Competition", 
            description: "Debug test", 
            signupDeadline: "2024-12-31T23:59:59", 
            ratingSchemeId: 1, 
            pid: 0,
            stages: [
                {
                    name: "Debug Stage 1",
                    description: "First debug stage",
                    matchTime: "2024-11-01T09:00:00",
                    ratingSchemeId: 1,
                    playerMax: 50
                }
            ]
        }) { 
            id name description pid 
        } 
    }'
} | ConvertTo-Json -Depth 10
 
$response1 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body1 -Headers $headers
Write-Host "Creation result:"
$response1 | ConvertTo-Json -Depth 10
 
if ($response1.data -and $response1.data.saveActivity) {
    $competitionId = $response1.data.saveActivity.id
    Write-Host "Competition created with ID: $competitionId"
    
    # Test: Query stages directly
    Write-Host "`n2. Querying stages directly..."
    $body2 = @{
        query = "query { 
            activityStages(competitionId: $competitionId) { 
                id name description playerMax pid
            } 
        }"
    } | ConvertTo-Json
    
    $response2 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body2 -Headers $headers
    Write-Host "Stages query result:"
    $response2 | ConvertTo-Json -Depth 10
    
    # Test: Query competition with stages
    Write-Host "`n3. Querying competition with stages..."
    $body3 = @{
        query = "query { 
            activity(id: $competitionId) { 
                id name description pid
                stages { id name description playerMax pid }
            } 
        }"
    } | ConvertTo-Json
    
    $response3 = Invoke-RestMethod -Uri "http://localhost:8080/api/graphql" -Method POST -Body $body3 -Headers $headers
    Write-Host "Competition query result:"
    $response3 | ConvertTo-Json -Depth 10
    
} else {
    Write-Host "Competition creation failed"
    if ($response1.errors) {
        Write-Host "Error details:"
        $response1.errors | ConvertTo-Json -Depth 10
    }
}