Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return fetch("/api/" + queryHash + "--" + variablesHash + ".json").then(function (v) {
console.log('gql-interface', v);
return v.json();
});
}
};
// Polyfill fetch
var client = new _apolloClient2.default({
networkInterface: gqlInterface,
initialState: window.__APOLLO_STATE__
});
(0, _reactDom.render)(_react2.default.createElement(
_reactApollo.ApolloProvider,
{ client: client },
_react2.default.createElement(
_reactRouterDom.BrowserRouter,
null,
_loadRoutes2.default
)
), document.getElementById("content"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9lbnRyeS1jbGllbnQuanMiXSwibmFtZXMiOlsiZ3FsSW50ZXJmYWNlIiwicXVlcnkiLCJ2YXJpYWJsZXMiLCJvcGVyYXRpb25OYW1lIiwiY29uc29sZSIsImxvZyIsInF1ZXJ5SGFzaCIsInZhcmlhYmxlc0hhc2giLCJmZXRjaCIsInRoZW4iLCJ2IiwianNvbiIsImNsaWVudCIsIm5ldHdvcmtJbnRlcmZhY2UiLCJpbml0aWFsU3RhdGUiLCJ3aW5kb3ciLCJfX0FQT0xMT19TVEFURV9fIiwiZG9jdW1lbnQiLCJnZXRFbGVtZW50QnlJZCJdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7OztBQUNBOztBQUNBOztBQUNBOzs7O0FBQ0E7O0FBRUE7O0FBRUE7Ozs7QUFDQTs7Ozs7O0FBRUEsSUFBTUEsZUFBZTtBQUNuQkMsT0FEbUIsdUJBQ3dCO0FBQUEsUUFBbkNBLE1BQW1DLFFBQW5DQSxLQUFtQztBQUFBLFFBQTVCQyxTQUE0QixRQUE1QkEsU0FBNEI7QUFBQSxRQUFqQkMsYUFBaUIsUUFBakJBLGFBQWlCOztBQUN6Q0MsWUFBUUMsR0FBUixDQUFZLE1BQVo7O0FBRHlDLHVCQUVKLDJCQUFZSixNQUFaLEVBQW1CQyxTQUFuQixDQUZJO0FBQUEsUUFFakNJLFNBRmlD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9idWlsZC9sb2FkLXJvdXRlc1wiO1xuaW1wb3J0IGhhc2hHUUxWYXJzIGZyb20gJy4vaGFzaC1ncWwtdmFycyc7XG5cbmNvbnN0IGdxbEludGVyZmFjZSA9IHtcbiAgcXVlcnkoeyBxdWVyeSwgdmFyaWFibGVzLCBvcGVyYXRpb25OYW1lIH0pIHtcbiAgICBjb25zb2xlLmxvZygnZ2ludCcpO1xuICAgIGNvbnN0IHsgcXVlcnlIYXNoLCB2YXJpYWJsZXNIYXNoIH0gPSBoYXNoR1FMVmFycyhxdWVyeSwgdmFyaWFibGVzKTtcbiAgICByZXR1cm4gZmV0Y2goYC9hcGkvJHtxdWVyeUhhc2h9LS0ke3ZhcmlhYmxlc0hhc2h9Lmpzb25gKS50aGVuKHYgPT4ge1xuICAgICAgY29uc29sZS5sb2coJ2dxbC1pbnRlcmZhY2UnLCB2KTtcbiAgICAgIHJldHVybiB2Lmpzb24oKTtcbiAgICB9KTtcbiAgfVxufTtcblxuY29uc3QgY2xpZW50ID0gbmV3IEFwb2xsb0NsaWVudCh7XG4gIG5ldHdvcmtJbnRlcmZhY2U6IGdxbEludGVyZmFjZSxcbiAgaW5pdGlhbFN0YXRlOiB3aW5kb3cuX19BUE9MTE9fU1RBVEVfX1xufSk7XG5cbnJlbmRlcihcbiAgPEFwb2xsb1Byb3ZpZGVyIGNsaWVudD17Y2xpZW50fT5cbiAgICA8QnJvd3NlclJvdXRlcj5cbiAgICAgIHtyb3V0ZXN9XG4gICAgPC9Ccm93c2VyUm91dGVyPlxuICA8L0Fwb2xsb1Byb3ZpZGVyPixcbiAgZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoXCJjb250ZW50XCIpXG4pO1xuIl19
enhanceElement: function(reactElement) {
return React.createElement(
ReactApollo.ApolloProvider,
{
client: this.client,
},
reactElement
);
},
};
render() {
return (React.createElement(react_apollo_1.ApolloProvider, { client: this.createClient() },
React.createElement(react_router_dom_1.Router, { history: history },
React.createElement(app_1.default, null))));
}
}
exports.default = function (locals, callback) {
debug(locals.path + " rendering");
var client = new _apolloClient2.default({
ssrMode: true,
networkInterface: gqlInterface
});
var ctx = {};
var component = _react2.default.createElement(
_reactApollo.ApolloProvider,
{ client: client },
_react2.default.createElement(
_reactRouter.StaticRouter,
{ location: locals.path, context: ctx },
_loadRoutes2.default
)
);
debug(locals.path + " getDataFromTree");
(0, _reactApollo.getDataFromTree)(component).then(function (context) {
debug(locals.path + " rendering body");
var body = _server2.default.renderToString(component);
var initialState = (0, _defineProperty3.default)({}, client.reduxRootKey, client.getInitialState());
var html = (0, _server.renderToStaticMarkup)(_react2.default.createElement(_loadHtml2.default, {
body: body,
assets: locals.assets,
var _Home = require('./components/Home/Home');
var _Home2 = _interopRequireDefault(_Home);
var _GraphiQL = require('./components/GraphiQL/GraphiQL');
var _GraphiQL2 = _interopRequireDefault(_GraphiQL);
var _apollo = require('../apollo');
var _apollo2 = _interopRequireDefault(_apollo);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
_reactDom2.default.render(_react2.default.createElement(
_reactApollo.ApolloProvider,
{ client: _apollo2.default },
_react2.default.createElement(
_reactRouter.Router,
{
history: _reactRouter.browserHistory,
routes: _reactRouter.routes,
render: (0, _reactRouter.applyRouterMiddleware)()
},
_react2.default.createElement(_reactRouter.Route, { path: '/', component: _App2.default }),
_react2.default.createElement(_reactRouter.Route, { path: '/home', component: _Home2.default }),
_react2.default.createElement(_reactRouter.Route, { path: '/graphiql', component: _GraphiQL2.default })
)
), document.getElementById('root'));
app.use(basicCache, function (req, res, next) {
global.navigator = { userAgent: req.headers['user-agent'] };
global.document = {
title: "Movie Rater",
meta: {
description: "蒐集了IMDB, YAHOO, PTT的電影評價,一目了然讓你不再踩雷",
image: "/public/favicons/android-chrome-384x384.png"
}
};
const client = new react_apollo_1.ApolloClient({
ssrMode: true,
networkInterface: apollo_local_query_1.createLocalInterface(graphql, schema_1.default),
});
const context = {};
const app = (React.createElement(react_apollo_1.ApolloProvider, { client: client },
React.createElement(react_router_dom_1.StaticRouter, { location: req.url, context: context },
React.createElement(app_1.default, null))));
react_apollo_1.renderToStringWithData(app).then(content => {
const initialState = { apollo: client.getInitialState() };
const page = swig.renderFile(staticRoot + 'bundles/index.html', {
title: global.document.title,
meta: global.document.meta,
html: content,
apolloState: ``
});
res.status(context["status"] || 200).send(page);
}, error => next(error));
});
app.use(function (err, req, res, next) {