反应继电器分页容器:意外令牌FRAGMENT_REFERENCE

时间:2018-08-08 12:30:59

标签: reactjs react-native graphql relayjs relay

我们正在尝试创建PaginationContainer以延迟加载用户。我们按照文档示例进行操作,并准备了片段和与之对应的查询。

中继编译器成功编译了所有内容并生成了文件,但是应用程序崩溃并出现以下错误,导致运行时崩溃:

simulator screen shot - iphone se - 2018-08-08 at 14 14 39

export default createPaginationContainer(
  ConnectedFeed,
  {
    feed: graphql`
      fragment Feed_feed on Query
        @argumentDefinitions(
          count: { type: "Int", defaultValue: 10 }
          cursor: { type: "ID" }
        ) {
        feed(first: $count, after: $cursor)
          @connection(key: "Feed_feed", filters: []) {
          edges {
            node {
              id
              age
              name
              profileImages
              userId
            }
          }
        }
      }
    `,
  },
  {
    direction: 'forward',
    getFragmentVariables(prevVars, totalCount) {
      return {
        ...prevVars,
        count: totalCount,
      }
    },
    getVariables(orops, { count, cursor }, fragmentVariables) {
      return {
        count,
        cursor,
      }
    },
    query: graphql`
      query FeedPaginationQuery($count: Int, $cursor: ID) {
        ...Feed_feed @arguments(count: $count, cursor: $cursor)
      }
    `,
    getConnectionFromProps(props) {
      return props.feed && props.feed.edges
    },
    getFragmentVariables(previousVariables, totalCount) {
      return {
        ...previousVariables,
        count: totalCount,
      }
    },
    getVariables(props, paginationInfo) {
      return {
        count: paginationInfo.count,
        after: paginationInfo.cursor,
      }
    },
  },
)

<QueryRenderer
  environment={environment}
  variables={{
    count: 10,
    cursor: null,
  }}
  query={graphql`
    query FeedScreenQuery($count: Int, $cursor: ID) {
      myProfile {
        id
        profileImages
      }
      ...Feed_feed @arguments(count: $count, cursor: $cursor)
    }
  `}
  render={queryProps => {
    if (!queryProps.props) return null
    return (
      <Feed
        {...this.props}
        queryProps={queryProps}
        myProfile={queryProps.props.myProfile}
        feed={queryProps.props.feed}
      />
    )
  }}
/>

打包版本:

"relay-compiler": "^1.6.0"
"relay": "^0.8.0-1",
"react-relay": "^1.6.0",
"graphql-relay-tools": "^0.1.1",
"react-native": "0.55.3",
"babel-plugin-relay": "^1.6.0",

是中继错误还是我们代码中的错误?我们无法搜索有关此错误的任何问题。

0 个答案:

没有答案