Graphql 更改FaunaDB中的对象列表

Graphql 更改FaunaDB中的对象列表,graphql,graphql-js,faunadb,Graphql,Graphql Js,Faunadb,我在FaunaDB中导入了GraphQL模式,希望创建一个新问题 type Choices { key: String! value: String! question: Question } type Question { title: String! snippet: String choices: [Choices!]! @relation answer: String! explanation: String! } type Query { all

我在FaunaDB中导入了GraphQL模式,希望创建一个新问题

type Choices {
  key: String!
  value: String!
  question: Question
}

type Question {
  title: String!
  snippet: String
  choices: [Choices!]! @relation
  answer: String!
  explanation: String!
}

type Query {
  allQuestions: [Question!]!
}
为此,我使用axios,并使GraphQL发生如下变化:

const CREATE_QUESTION = `
mutation($title: String!, $explanation: String!, $snippet: String, $answer: String!, $choices: [ChoicesInput]!) {
  createQuestion(data: {
    title: $title
    explanation: $explanation,
    snippet: $snippet,
        answer: $answer,
    choices: {
      create: $choices
    }
  }) {
    _id
    explanation
    answer
    title
    snippet
    choices {
      data {
        key
        value
      }
    }
  }
}
`
除选项外,所有操作都正常,我想发送一个对象数组,但出现错误:

变量“$choices”类型的预期值“[ChoicesInput]”但是得到:“[{key:'A',value:'0112'和'0112`},{key:'B',value:'0112'和'3333`},{key:'C',value:'333'和'0112`}]”。原因:“[0]”应为“ChoiceInput”,但未找到对象。(第2行第86列):突变($title:String!,$explainion:String!,$snippet:String,$answer:String!,$choices:[ChoicesInput]!){^


为了能够发送我的对象数组,我应该做些什么不同的事情?

听起来你是在传递字符串,而不是对象数组,作为$choices的值。你的问题不清楚变量是如何传递到axios的。请显示所有相关代码这是调用`const result=wait axios({url:,方法:“POST”,标题:{Authorization:
Bearer${process.env.FAUNA_SERVER_SECRET}
},数据:{query,variables}}}})`请编辑您的问题。我们需要了解您实际上是如何构造variables对象的,特别是它的choices属性的。