我在Electron容器中使用带有CRA的Relay,但出现了一个似乎无法诊断的非常奇怪的错误:似乎GraphQL片段在导入时包含Webpack工件?
@bot.event
async def on_command_error(ctx, error):
if isistance(error, bot.MyException):
await ctx.send("{} went wrong!".format(error.argument))
else:
print(error)
Webpack是否以某种方式编译Could not create Relay Container for `UsersGrid`. Expected a set of GraphQL fragments, got `function () {
const node = __webpack_require__(/*! ./__generated__/UsersGrid_viewer.graphql */ "./src/components/users-grid/__generated__/UsersGrid_viewer.graphql.js");
文件?还是我还要看其他东西?
这是中继容器:
.graphql.js
正在被内联编译为:
import { createFragmentContainer, graphql } from 'react-relay';
import UsersGrid from './UsersGrid';
export default createFragmentContainer(
UsersGrid,
graphql`
fragment UsersGrid_viewer on Query {
user(login: "jvcjunior") {
followers(first: 10) {
edges {
node {
name
avatarUrl
}
}
}
}
}
`
);
答案 0 :(得分:2)
尝试使用
createFragmentContainer(Component, {
viewer: graphql`
fragment UsersGrid_viewer on Query { ... }
`
})
代替
createFragmentContainer(Component,
graphql`
fragment UsersGrid_viewer on Query { ... }
`
)