带空字符串值的graphql mutate对象

时间:2019-06-14 20:02:53

标签: graphql apollo mutation vue-apollo

我正在尝试使用onChange

对graphql查询进行变异
vue-apollo

但是出现以下错误:

let fields = [
  { name: 'A', value: '0' },
  { name: 'B', value: '' }
]
this.$apollo
  .mutate({
    mutation: gql`
      mutation($serve: Int!, $fields: [ComponentInput]) {
        visitCreate(serve: $serve, fields: $fields) {
          id
          ...
        }
      }
    `,
    variables: {
      serve: this.serve.id,
      fields: fields
    }
  })

实际上Variable "$fields" got invalid value [{"name":"A","value":"0"},{"name":"B","value":null}]; Expected non-nullable type String! not to be null at value[1].value 应该是fields,我不知道怎么做。

我也尝试过[{"name":"A","value":"0"},{"name":"B","value":""}]

enter image description here

请帮忙

0 个答案:

没有答案