Edg*_*rka 5 javascript node.js graphql
我尝试发布突变查询抛出我的nodejs基础grapqlapi。
我在服务器端的架构:
...
input PostPickProps {
userId: String
matchId: String
predictionModelId: String
modelVersionNumber: Int
modelVariationIndex: Int
pickEnd: String
}
type Mutation {
postPick(props: PostPickProps): String
}
...
Run Code Online (Sandbox Code Playgroud)
从应用程序查询:
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
}
Run Code Online (Sandbox Code Playgroud)
我在服务器端的解析器:
export const postPick = async ({ props }) => {
const {
pickEnd,
matchId,
userId,
predictionModelId,
modelVersionNumber,
modelVariationIndex,
} = props
console.log(props) // output [Object: null prototype] { userId: 'hack' ...}
...
Run Code Online (Sandbox Code Playgroud)
console.log 输出不符合预期:
[Object: null prototype] {
userId: '5cb51b16e6161e6e5cb51b16',
matchId: '5cb51b16e6161e6e401262c2',
predictionModelId:'5ca0f4afb88b3a2e006faa0d', ....
Run Code Online (Sandbox Code Playgroud)
我怀疑获取在我的架构中声明的 props 对象。