简体   繁体   English

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

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

Seeing this error when attempting to save a Compat mode mutation. 尝试保存Compat模式突变时看到此错误。 It seems it may have to do with the Relay-specific part of the query (edge/node). 似乎可能与查询的中继特定部分(边缘/节点)有关。 How can we fix this? 我们该如何解决?

Query is minimally updated from what worked in Relay Classic - only the newWorkoutEntryEdge has been fleshed out to fetch the node and child members. 查询仅从Relay Classic中的工作中进行了最少的更新-仅对newWorkoutEntryEdge进行了充实,以获取节点和子成员。

Mutation code: 变异码:

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 });
}

在此处输入图片说明

After tracing this through the Relay code, I realized I was passing an object with mutationQuery as a field, rather than mutation , so Relay couldn't find the expected mutation field. 在通过Relay代码跟踪此内容之后,我意识到我正在传递一个以mutationQuery作为字段而非mutation ,因此Relay无法找到预期的突变字段。

Changing this 改变这个

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

to this 对此

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

solved the problem. 解决了问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM