How to use the react-relay.DefaultNetworkLayer function in react-relay

To help you get started, we’ve selected a few react-relay examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tubackkhoa / tkframework / mobile / ReactNotes / ui / index.js View on Github external
import React, { Component } from 'react'
import Relay, {
  DefaultNetworkLayer,
} from 'react-relay'

import { API_BASE } from 'ReactNotes/store/constants/api'

import App from './containers/App'

import { Provider } from 'react-redux'

import { store } from 'ReactNotes/store/config'

Relay.injectNetworkLayer(
  new DefaultNetworkLayer(`${API_BASE}/graphql`)
)

export default props => (
  
    
  
)

// hotfix in case babel remove console does not work
if(!__DEV__) {
    console = {};
    console.log = () => {};
    console.error = () => {};
}
github lenaten / react-native-relay / index.ios.js View on Github external
/* @flow */
'use strict';

import React from 'react-native';
import Relay from 'react-relay';
import FixApp from './src/components/FixApp';
import ViewerRoute from './src/routes/ViewerRoute';
import config from './config';

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer(config.graphqlURL)
);

var {
  AppRegistry,
} = React;

class fix extends React.Component {
  render() {
    var viewerRoute = new ViewerRoute();
    return (
        
    );
  }
github ticruz38 / Ambrosia / client / desktop.js View on Github external
import Board from './components/board/board';
import BoardTimeLine from './components/board/timeline';
import BoardCardIndex from './components/board/cardindex';
import BoardCard from './components/board/card';
import BoardSettings from './components/board/settings';
import Ordering from './components/ordering';
import Profile from './components/profile';
import React from 'react';
import ReactDom from 'react-dom';
import {createHistory} from 'history';
import Relay from 'react-relay';
// import rootQuery from '../indexroute.js';
import { RelayRouter } from 'react-router-relay';

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('/graphql', {
    credentials: 'same-origin'
  })
);

const ViewerQuery = {
  user: () => Relay.QL `query { root }`
};

const RestaurantQuery = {
  restaurant: () => Relay.QL `query {root (id: $id)}`
};

const RestaurantsQuery = {
  restaurant: () => Relay.QL `query {root}`
};
//I pass restaurant id to root and then from root to restaurant in the schema.js field
github learnrelay / pokedex / branch-step-04 / src / index.js View on Github external
import React from 'react'
import Relay from 'react-relay'
import ReactDOM from 'react-dom'
import PokemonPage from './views/PokemonPage'
import ListPage from './views/ListPage'
import { Router, Route, browserHistory, applyRouterMiddleware } from 'react-router'
import useRelay from 'react-router-relay'
import './index.css'

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('https://api.graph.cool/relay/v1/__PROJECT_ID__')
)

const ViewerQueries = { viewer: () => Relay.QL`query { viewer }` }

ReactDOM.render(
  
    
  
  , document.getElementById('root')
)
github papigers / question-it / client / index.jsx View on Github external
function run() {
  const environment = new Relay.Environment();
  environment.injectNetworkLayer(new Relay.DefaultNetworkLayer('/graphql', {
    credentials: 'same-origin',
  }));

  const data = JSON.parse(document.getElementById('preloadedData').textContent);

  IsomorphicRelay.injectPreparedData(environment, data);

  injectTapEventPlugin();

  match({ routes, history: browserHistory }, (error, redirectLocation, renderProps) => {
    IsomorphicRouter.prepareInitialRender(environment, renderProps).then(props => {
      render(
github charlieschwabacher / gestalt / packages / blogs-example / client / index.js View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import Relay, {DefaultNetworkLayer} from 'react-relay';
import {Router, browserHistory, applyRouterMiddleware} from 'react-router';
import useRelay from 'react-router-relay';
import routes from './routes';

Relay.injectNetworkLayer(
  new DefaultNetworkLayer('/graphql', {
    credentials: 'include',
  })
);

ReactDOM.render(
  ,
  document.getElementById('root')
);
github facebook / relay / examples / TodoMVC / app.js View on Github external
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

'use strict';

import TodoApp from './components/TodoApp';
import TodoAppRoute from './routes/TodoAppRoute';
import React, { Component } from 'react';
import Relay, {
  DefaultNetworkLayer,
  RootContainer,
} from 'react-relay';

Relay.injectNetworkLayer(
  new DefaultNetworkLayer('http://localhost:8080')
);

export default class TodoMVC extends Component {
  render(): void {
    return (
      
    );
  }
}
github artsy / reaction / src / Apps / Loyalty / Server / Middlewares / Relay.ts View on Github external
export default function RelayMiddleware(req: Request, res: Response, next: NextFunction) {
  const { CURRENT_USER } = res.locals.sd
  let options = {
    headers: !!CURRENT_USER
      ? {
          "X-USER-ID": CURRENT_USER.id,
          "X-ACCESS-TOKEN": CURRENT_USER.accessToken,
        }
      : {},
  }

  res.locals.networkLayer = new Relay.DefaultNetworkLayer(process.env.METAPHYSICS_ENDPOINT, options)

  next()
}
github learnrelay / pokedex / branch-step-01 / src / index.js View on Github external
import React from 'react'
import Relay from 'react-relay'
import ReactDOM from 'react-dom'
import ListPage from './views/ListPage'
import { Router, Route, browserHistory, applyRouterMiddleware } from 'react-router'
import useRelay from 'react-router-relay'
import './index.css'

Relay.injectNetworkLayer(
  new Relay.DefaultNetworkLayer('https://api.graph.cool/relay/v1/__PROJECT_ID__')
)

ReactDOM.render(
  
    
  
  , document.getElementById('root')
)