我目前使用 Lighthouse 作为 laravel 的 graphql 服务器。我已经阅读了他们网站上的订阅文档(https://lighthouse-php.com/master/subscriptions/getting-started.html),并将适当的推送器凭据添加到 .env 文件中。
尝试通过 graphql-playground UI 订阅时,出现以下错误:
订阅:
subscription {
orgUserCreated {
org
}
}
错误:
{
"error": "Could not connect to websocket endpoint ws://localhost:8000/graphql. Please check if the endpoint url is correct."
}
所有突变和查询都在正常工作。
我已经覆盖了 laravel-graphql-playground laravel 的 index.blade.php 文件,并且可以向该文件添加一个“subscriptionEndpoint”变量,但不清楚该变量应该包含什么。
<script type="text/javascript">
window.addEventListener('load', function (event) {
const loadingWrapper = document.getElementById('loading-wrapper');
loadingWrapper.classList.add('fadeOut');
const root = document.getElementById('root');
root.classList.add('playgroundIn');
GraphQLPlayground.init(root, {
endpoint: "{{url(config('graphql-playground.endpoint'))}}",
subscriptionEndpoint: "?"
})
})
</script>
由于我通过推送器连接,有谁知道“subscriptionEndpoint”变量中应该包含什么?