将变量传递给`Relay.QL`

时间:2017-04-19 19:25:45

标签: relayjs relay

这是一种使用 Relay.QL 来捕捉变量的方法吗?

SubredditQuery.js

import Relay from 'react-relay'

const SubredditQuery = {
  subreddit: () => Relay.QL`
    query {
      subreddit(name: "Futurology")
    }
  `,
}

export default SubredditQuery

App.js

export default createRenderer(ReactNativeRelay, {
  queries: SubredditQuery,
  fragments: {
    subreddit: () => Relay.QL`
      fragment on RedditSubreddit {
        title
        hotListings {
          title
          score
          url
          author {
            username
          }
        }
      }
    `,
  },
})

我需要使用变量 $ name 而不是硬编码“Futurology”。有什么办法吗?感谢

0 个答案:

没有答案