graphql突变参数名称为[对象:null原型]

时间:2019-04-17 13:39:58

标签: javascript node.js graphql

我尝试发布突变查询,并抛出基于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对象。

0 个答案:

没有答案