![](/img/trans.png)
[英]Authentication and Authorization with Django GraphQL JWT and Graphene Relay
[英]graphene django relay: Relay transform error
作為GraphQL的新手,我有一個帶有兩個模型的服務器的石墨烯django實現,非常接近石墨烯文檔的示例 。
在graphiql中,我可以執行此操作,然后返回結果。
在另一個中繼教程之后 ,我打算在屏幕上呈現此查詢的結果。
我的嘗試如下所示:
class Note extends Component {
render() {
return(
<div> {this.props.store.title} </div>
)
}
}
Note = Relay.createContainer(Note, {
fragments: {
store: () => Relay.QL`
fragment on Query {
note(id: "Tm90ZU5vZGU6MQ==") {
id
title
}
}
`
}
});
class NoteRoute extends Relay.Route {
static routeName = 'NoteRoute';
static queries = {
store: Component => {
return Relay.QL`
query {
${Component.getFragment('store')}
}
`},
};
}
我的瀏覽器的控制台顯示以下錯誤:
Uncaught Error: Relay transform error ``There are 0 fields supplied to the query named `Index`, but queries must have exactly one field.`` in file `/Users/.../src/index.js`. Try updating your GraphQL schema if an argument/field/type was recently added.
我一直在嘗試自己解決問題,但成效有限。
有人可以指出我正確的方向嗎?
感謝@stubailo為我指出正確的方向。 我進行了一些調整,現在有一個運行如下的最小示例:
NoteList = Relay.createContainer(NoteList, {
fragments: {
store: () => Relay.QL`
fragment N on NoteNodeConnection {
edges {
node{
id
title
note
}
}
}
`
}
});
class NoteRoute extends Relay.Route {
static routeName = 'NoteRoute';
static queries = {
store: Component => {
return Relay.QL`
query {
notes {
${Component.getFragment('store')}
}
}
`},
};
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.