Open Stanislav-Lapata opened 4 years ago
You can get it to work with something like this (works with relay 9):
import { Observable } from "relay-runtime";
// ...
const legacySubscribe = createSubscriber(withAbsintheSocket.create(socket));
// @absinthe/socket-relay is outdated so wrap it with a fix
const subscribe = (request, variables, cacheConfig) => {
return Observable.create(sink => {
legacySubscribe(request, variables, cacheConfig, {
onNext: sink.next,
onError: sink.error,
onCompleted: sink.complete
});
});
};
const environment = new Environment({
network: Network.create(fetchQuery, subscribe),
store: new Store(new RecordSource())
});
export default environment;
@stephan83's solution fixed the problem for me (react-relay@9.1
).
I had a bunch of TypeError
as follow when using subscriptions with react-relay
>= 6.0.0
:
TypeError: undefined is not an object (evaluating '_ref3.onError')
Maybe @absinthe/socket-relay should implement @stephan83's solution or update RelayObservable
's API to work with newer versions.
react-relay: 8.0.0 @absinthe/socket-relay: 0.2.1
environment.js
component.js
Sorry I'm new to JS RelayNetwork expects a function with 3 arguments?