apollo客户端-“试图写入没有提供id错误的对象”查询

时间:2018-08-04 18:21:16

标签: graphql apollo-client apollo-angular

我在有角度的应用程序中使用apollo客户端。查询是这样的。请注意,当isProduction = false时,数据库中的fkElectricityTypeId为null。

query GetTurnoversBySmartMeterId($id: UUID!, $start: Datetime!) {
    smartMeterById(id: $id) {
        id
        isProduction
        fkElectricityTypeId
        electricityType: electricityTypeByFkElectricityTypeId {
            name
        }
        energyTurnovers: energyTurnoversByFkSmartMeterId(filter: { timestamp: { greaterThan: $start } }) {
            nodes {
                id
                amount
                timestamp
            }
        }
    }
}

仅对于具有isProduction = true的smartMeterIds,我会收到这样的错误。即使经过研究,该错误通常与突变有关。我认为这与阿波罗有关,因为我可以使用例如执行相同的查询GraphQl App没有任何问题...

core.js:1633 ERROR Error: Network error: Error writing result to store for query:
 query GetTurnoversBySmartMeterId($id: UUID!, $start: Datetime!) {
  smartMeterById(id: $id) {
    id
    isProduction
    electricityType: electricityTypeByFkElectricityTypeId {
      name
      __typename
    }
    energyTurnovers: energyTurnoversByFkSmartMeterId(filter: {timestamp: {greaterThan: $start}}) {
      nodes {
        id
        amount
        timestamp
        __typename
      }
      __typename
    }
    __typename
  }
}

Store error: the application attempted to write an object with no provided id but the store already contains an id of ElectricityType:b6d1bf0d-5c69-4e8a-8a68-e9baeb38d765 for this object. The selectionSet that was trying to be written is:
electricityType: electricityTypeByFkElectricityTypeId {
  name
  __typename
}

0 个答案:

没有答案