I am using apollo graphql to make https-based calls to my graphene backend. Queries and mutations work fine. In trying to add support for graphql subscriptions, I tried modifying my client setup code to include:
// Create a WebSocket link:
const wsLink = new WebSocketLink({
uri: "wss://" + hostname + "/graphql/",
options: {
reconnect: true,
}
});
const splitLink = split(
({ query }) => {
const definition = getMainDefinition(query);
return (
definition.kind === 'OperationDefinition' &&
definition.operation === 'subscription'
);
},
wsLink,
httpLink,
);
But I end up getting this error in the client:
WebSocket connection to 'wss://localhost/graphql/' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID
In looking at the docs (and exploring the APIs), I could not figure out how to configure WebSocketLink to accept a self-signed certificate. I am pretty sure that for development environments, all developers code with self signed certificates, so I know this should be doable. Any help in getting this working is much appreciated.
Interestingly, the HttpLink that I use for queries and mutations does not complain of the same self-signed certificates. If anyone from the apollo team sees this question, they should consider unifying the behavior of the two link types.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…