Codex Assistant
昨天 58d9f460b2f8c34430285115e2557d18333c5cab
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// 测试小程序端修复后的GraphQL查询
const axios = require('axios');
 
const testQuery = `
  query GetActivityPlayerDetail($id: ID!) {
    activityPlayerDetail(id: $id) {
      id
      projectName
      description
      activityName
      stageId
      state
      playerInfo {
        id
        name
        phone
        gender
        birthday
        education
        introduction
        userInfo {
          userId
          name
          phone
          avatarUrl
        }
      }
      regionInfo {
        id
        name
        fullPath
      }
      submissionFiles {
        id
        name
        url
        fullUrl
        fileExt
        fileSize
        mediaType
        thumbUrl
        fullThumbUrl
      }
      ratingForm {
        schemeId
        schemeName
        totalMaxScore
        items {
          id
          name
          maxScore
          orderNo
        }
      }
    }
  }
`;
 
async function testGraphQLQuery() {
  try {
    console.log('测试修复后的小程序端GraphQL查询...');
    
    const response = await axios.post('http://localhost:8080/api/graphql', {
      query: testQuery,
      variables: {
        id: "1" // 使用一个测试ID
      }
    }, {
      headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer test-token' // 如果需要认证
      }
    });
 
    if (response.data.errors) {
      console.error('GraphQL查询出错:', response.data.errors);
      return false;
    }
 
    console.log('✅ GraphQL查询成功!');
    console.log('返回的数据结构:', JSON.stringify(response.data.data, null, 2));
    return true;
 
  } catch (error) {
    console.error('❌ 请求失败:', error.message);
    if (error.response) {
      console.error('响应状态:', error.response.status);
      console.error('响应数据:', error.response.data);
    }
    return false;
  }
}
 
// 运行测试
testGraphQLQuery().then(success => {
  if (success) {
    console.log('\n🎉 小程序端GraphQL查询修复成功!');
    console.log('现在小程序端查询的字段与Web端保持一致,不再包含不存在的description、weight、sortOrder字段。');
  } else {
    console.log('\n❌ 测试失败,请检查修复是否正确。');
  }
});