这是一种使用 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”。有什么办法吗?感谢