我尝试发布突变查询,并抛出基于nodejs
的{{1}} api。
我在服务器端的架构:
grapql
从应用程序查询:
...
input PostPickProps {
userId: String
matchId: String
predictionModelId: String
modelVersionNumber: Int
modelVariationIndex: Int
pickEnd: String
}
type Mutation {
postPick(props: PostPickProps): String
}
...
我在服务器端的解析器:
export const postPick = async ({
userId,
matchId,
predictionModelId,
modelVersionNumber,
modelVariationIndex,
pickEnd
}) => {
const res = await fetch(`
mutation {
postPick(props: {
userId: "${userId}"
matchId: "${matchId}"
predictionModelId: "${predictionModelId}"
modelVersionNumber: ${modelVersionNumber}
modelVariationIndex: ${modelVariationIndex}
pickEnd: "${pickEnd}"
})
}
`)
return res
}
console.log输出与预期不符:
export const postPick = async ({ props }) => {
const {
pickEnd,
matchId,
userId,
predictionModelId,
modelVersionNumber,
modelVariationIndex,
} = props
console.log(props) // output [Object: null prototype] { userId: 'hack' ...}
...
我怀疑在我的模式中声明了获取props对象。