graphql-pouch icon indicating copy to clipboard operation
graphql-pouch copied to clipboard

Post creation fails in cms-relay example

Open fgnass opened this issue 8 years ago • 3 comments

When I try to create a Post in the cms-relay example, I get the following network error: main.js:31381 POST http://localhost:3001/graphql 404 (Not Found)

I assume the port should be 3000 instead of 3001? At least the initial request goes to http://localhost:3000/graphql/cms/_subscribe.

Is this a bug or am I missing something important?

fgnass avatar Jun 03 '17 22:06 fgnass

It works if I add Relay.injectNetworkLayer(networkLayer); to main.js but since I'm new to Relay I have no idea if this is how this is supposed to be ;)

fgnass avatar Jun 04 '17 08:06 fgnass

I'm having the same trouble @fgnass . Where in main.js did you add Relay.injectNetworkLayer(networkLayer);?

joshglenn avatar Apr 13 '19 21:04 joshglenn

Ok. Got this working. In my case, I added the line:

Relay.injectNetworkLayer(new NetworkLayer(window.__env.ENDPOINT));

below the line:

environment.injectNetworkLayer(new NetworkLayer(window.__env.ENDPOINT));

main.jsx now looks like this:

import React from 'react';
import ReactDOM from 'react-dom';
import Relay from 'react-relay';
import { Router, browserHistory, applyRouterMiddleware } from 'react-router';
import useRelay from 'react-router-relay';
import routes from './routes';
import RelaySubscriptions from 'relay-subscriptions';
import NetworkLayer from './NetworkLayer';

const environment = new RelaySubscriptions.Environment();
environment.injectNetworkLayer(new NetworkLayer(window.__env.ENDPOINT));
Relay.injectNetworkLayer(new NetworkLayer(window.__env.ENDPOINT));


ReactDOM.render(
  <Router
    history={browserHistory}
    routes={routes}
    render={applyRouterMiddleware(useRelay)}
    environment={environment}
  />,
  document.getElementById('render_body')
);

joshglenn avatar Apr 14 '19 04:04 joshglenn