apollo收到的数组数据重复最后一条记录

时间:2017-07-01 10:04:34

标签: graphql apollo

从graphql中获取数据 - 表达服务器并包含



course
:
["MAT", "FEN", "SOSYAL"]
list
:
[{_id: {totGrade: 11, totLetter: "B", __typename: "StudentNumbersSub"}, countx: 1,…},…]
0
:
{_id: {totGrade: 11, totLetter: "B", __typename: "StudentNumbersSub"}, countx: 1,…}
1
:
{_id: {totGrade: 10, totLetter: "C", __typename: "StudentNumbersSub"}, countx: 1,…}
2
:
{_id: {totGrade: 9, totLetter: "B", __typename: "StudentNumbersSub"}, countx: 3,…}
3
:
{_id: {totGrade: 10, totLetter: "B", __typename: "StudentNumbersSub"}, countx: 2,…}
4
:
{_id: {totGrade: 9, totLetter: "A", __typename: "StudentNumbersSub"}, countx: 2,…}




所以正确的数据即将发布,但是从apollo对象订阅后



  this.dataPeriodService.serverQueryData.subscribe(({data}) => {
    console.log ('received data:', data);
    }




数据对象仅在此示例中以数组长度计数重复最后一条记录

{_ id:{totGrade:9,totLetter:" A",__typename:" StudentNumbersSub"},countx:2,...}

所以它只包含此记录

如何解决这个问题?

非常感谢!

1 个答案:

答案 0 :(得分:0)

我解决了为_id字段添加别名但似乎不可靠的