// 测试小程序端修复后的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❌ 测试失败,请检查修复是否正确。');
|
}
|
});
|