我正在尝试通过我的React Native应用和Rails Graphql服务器设置订阅,但出现以下错误消息
未处理的GraphQL订阅错误ReferenceError:未定义文档
我怀疑我使用的一个库正在使用文档,但是不确定哪个库和示例库是为React应用而不是React Native设置的。
我遵循了本指南:https://haughtcodeworks.com/blog/software-development/graphql-rails-react-standalone/
这是我的app.js设置
...
const httpLink = createHttpLink({
uri: `${global.URL}/graphql`,})
const cable = actionCable.createConsumer('ws://localhost:3000/cable')
const hasSubscriptionOperation = ({ query: { definitions } }) => {
return definitions.some(
({ kind,operation }) => kind === 'OperationDefinition' && operation === 'subscription',)
}
const link = ApolloLink.split(
hasSubscriptionOperation,new actionCableLink({cable}),httpLink
)
const client = new ApolloClient({
link: link,cache: new InmemoryCache()
})
return (
<ApolloProvider client={client}>
<Root />
</ApolloProvider>
)
我愿意共享更多代码,但由于我不确定错误可能来自何处,因此我首先需要一些指导。