1
我下面一個繼電器的教程,我感到困惑與這部分代碼:我很困惑Relay.QL片段,中繼的查詢和路由?
exports.Container = Relay.createContainer(ConferenceApp, {
/* 1st id on mock database */
initialVariables: {
userToShow: 1
},
fragments: {
user:() => Relay.QL`
/* what is this fragment on 'User'? does this has to be the name on/from the UserType Schema or this could be anything? */
fragment on User {
name,
conferences(userToShow: $userToShow) {
edges {
node {
id,
name,
description
},
},
},
}
`
},
});
exports.queries = {
name: 'ConferenceQueries',
params: {}, // what is params purpose here?
queries: {
user:() => Relay.QL`query { user }` // why do we have this user query when we have the query above?, what is this user field?
},
}
而且對應用程序的根,我在文檔閱讀,我只是需要有很強的把握,我我有這個OCD
<Relay.RootContainer
Component={ConferenceApp.Container}
route={ConferenceApp.queries} // is this something like react router? :/
onReadyStateChange={({error}) => { if (error) console.error(error) }} />
我把我的問題的意見,特別指出。真的很感謝那些部分的解釋,謝謝。