Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post creation fails in cms-relay example #27

Open
fgnass opened this issue Jun 3, 2017 · 3 comments
Open

Post creation fails in cms-relay example #27

fgnass opened this issue Jun 3, 2017 · 3 comments

Comments

@fgnass
Copy link

fgnass commented Jun 3, 2017

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
Copy link
Author

fgnass commented Jun 4, 2017

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 ;)

@joshglenn
Copy link
Contributor

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

@joshglenn
Copy link
Contributor

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')
);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants