中继现代兼容模式:未定义不是对象(评估 'taggedNode[CLASSIC_NODE]')

Relay Modern compat mode: undefined is not an object (evaluating 'taggedNode[CLASSIC_NODE]')

尝试保存兼容模式变更时看到此错误。它似乎与查询的中继特定部分有关 (edge/node)。我们该如何解决这个问题?

查询从 Relay Classic 中的工作进行了最低限度的更新 - 只有 newWorkoutEntryEdge 被充实以获取节点和子成员。

突变代码:

const mutationQuery = graphql`
mutation AddWorkoutEntryMutation($input: AddWorkoutEntryInput!, 
    $dateOfEntry: String!) {
  AddWorkoutEntry(input: $input) {
    clientMutationId
    newWorkoutEntryEdge {
      node {
        id
        category
        description
        notes
        countOfRepetitions
      }
    }
    userData {
      id,
      workoutEntries(first: 10000,
          dateOfEntries: $dateOfEntry)
        {
        edges {
          node {
            id
            category
            description
            notes
            countOfRepetitions
          }
        }
      }
    }
  }
}`
;
export default function AddWorkoutEntryMutation(
  notes: string,
  countOfRepetitions: string,
  dateOfEntry: string,
  standardWorkoutID: string,
  userDataID: string)
  {
  const variables = {
    input: {
      notes,
      countOfRepetitions,
      dateOfEntry,
      standardWorkoutID
    },
    // possibly redundant
    dateOfEntry
  };
  commitMutation(Relay.Store, { mutationQuery, variables });
}

通过 Relay 代码进行跟踪后,我意识到我传递的对象是 mutationQuery 作为字段,而不是 mutation,因此 Relay 无法找到预期的突变字段。

改变这个

commitMutation(Relay.Store, { mutationQuery, variables });

至此

commitMutation(Relay.Store, { mutation, variables });

解决了问题。