graphene django relay:中继转换错误
graphene django relay: Relay transform error
作为 GraphQL 的新手,我有一个具有两个模型的服务器的 graphene django 实现,非常接近 graphene docs' example。
在 graphiql 中,我可以这样做,并返回结果。
在另一个 relay tutorial 之后,我打算在屏幕上呈现此查询的结果。
我的尝试是这样的:
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')}
}
}
`},
};
}
作为 GraphQL 的新手,我有一个具有两个模型的服务器的 graphene django 实现,非常接近 graphene docs' example。
在 graphiql 中,我可以这样做,并返回结果。
在另一个 relay tutorial 之后,我打算在屏幕上呈现此查询的结果。
我的尝试是这样的:
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')}
}
}
`},
};
}