Skip to content

Commit

Permalink
feat(graphql): disable data fetching in static ssr
Browse files Browse the repository at this point in the history
BREAKING CHANGE: In static mode, during server side rendering, GraphQL
data is no longer being prefetched. That appears to be the sane default.
The old behaviour can be restored by extending `GraphQLContext` and
overriding its 'prefetchData' method.

Closes #324
  • Loading branch information
dmbch committed Jan 25, 2018
1 parent 3ea65b3 commit 4e5e28a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/graphql/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exports.GraphQLContext.prototype = Object.assign({}, common, {
return introspectionResult;
},
getTemplateData: function(templateData, rootElement) {
return ReactApollo.getDataFromTree(rootElement).then(
return this.prefetchData(rootElement).then(
function() {
return Object.assign({}, templateData, {
globals: (templateData.globals || []).concat([
Expand All @@ -38,6 +38,11 @@ exports.GraphQLContext.prototype = Object.assign({}, common, {
}.bind(this)
);
},
prefetchData: function(rootElement) {
return process.env.HOPS_MODE !== 'static'
? ReactApollo.getDataFromTree(rootElement)
: Promise.resolve();
},
});

exports.contextDefinition = exports.GraphQLContext;
Expand Down

0 comments on commit 4e5e28a

Please sign in to comment.