Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
naming changes
Browse files Browse the repository at this point in the history
  • Loading branch information
James Baxley committed Jun 28, 2016
1 parent c9b9476 commit 81d0956
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function getQueriesFromTree({
}

// XXX component Cache
export function getData(
export function getDataFromTree(
components,
defaultProps: Object = {},
defaultContext: Object = {}
Expand Down Expand Up @@ -204,7 +204,7 @@ export function getData(
if (!child) return;

// traverse children nodes
return getData(child, defaultProps, context);
return getDataFromTree(child, defaultProps, context);
});
return Promise.all(subTrees);
})
Expand All @@ -213,7 +213,7 @@ export function getData(
}

export function renderToStringWithData(component) {
return getData(component)
return getDataFromTree(component)
.then(({ context }) => {
let markup = ReactDOM.renderToString(component);
let initialState = context.store.getState();
Expand All @@ -225,7 +225,7 @@ export function renderToStringWithData(component) {
for (let field of fieldsToNotShip) delete initialState[key].queries[queryId][field];
}
initialState = encodeURI(JSON.stringify(initialState));
const payload = `<script>window.__apollo_data__ = ${initialState};</script>`;
const payload = `<script>window.__APOLLO_STATE__ = ${initialState};</script>`;
markup += payload;
return markup;
});
Expand Down
12 changes: 6 additions & 6 deletions test/server/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom/server';
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { connect, ApolloProvider } from '../../src';
import { getData, renderToStringWithData } from '../../src/server';
import { getDataFromTree, renderToStringWithData } from '../../src/server';
import 'isomorphic-fetch';

import gql from 'graphql-tag';
Expand Down Expand Up @@ -55,7 +55,7 @@ describe('SSR', () => {
}
});

describe('`getData`', () => {
describe('`getDataFromTree`', () => {
it('should run through all of the queries that want SSR', (done) => {
const Element = ({ data }) => {
return <div>{data.loading ? 'loading' : data.currentUser.firstName}</div>;
Expand Down Expand Up @@ -102,7 +102,7 @@ describe('SSR', () => {
</ApolloProvider>
);

getData(app)
getDataFromTree(app)
.then(() => {
const markup = ReactDOM.renderToString(app);
expect(markup).to.match(/James/);
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('SSR', () => {
</ApolloProvider>
);

getData(app)
getDataFromTree(app)
.then(({ initialState }) => {
expect(initialState.apollo.data).to.exist;
expect(initialState.apollo.data['ROOT_QUERY.currentUser']).to.exist;
Expand Down Expand Up @@ -203,7 +203,7 @@ describe('SSR', () => {
</ApolloProvider>
);

getData(app)
getDataFromTree(app)
.then(({ initialState }) => {
expect(initialState.apollo.data).to.exist;
expect(initialState.apollo.data['ROOT_QUERY.currentUser']).to.not.exist;
Expand Down Expand Up @@ -389,7 +389,7 @@ describe('SSR', () => {
expect(markup).to.match(/Return of the Jedi/);
expect(markup).to.match(/Planets/);
expect(markup).to.match(/Tatooine/);
expect(markup).to.match(/__apollo_data__/);
expect(markup).to.match(/__APOLLO_STATE__/);
done();
})
.catch(done);
Expand Down

0 comments on commit 81d0956

Please sign in to comment.