我正在尝试使用来改变 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":""}]
,我不知道如何。
我也试过JSON.stringify(fields)
请有任何帮助