-
Notifications
You must be signed in to change notification settings - Fork 786
Can't import getDataFromTree
or renderToStringWithData
#387
Comments
graphql
decorator to work server-side?getDataFromTree
or renderToStringWithData
This threw me as well. The browser build deliberately doesn't feature the |
Hey Ben, Thanks for the response! I am indeed compiling this code with webpack, but I do have I actually did end up doing the same import trick! I wrote a TODO to remind me to fix it later, but perhaps it's not necessarily "broken." I'll make a note to see if I can figure out why webpack isn't bundling the correct file. |
Hey @GRardB, if you can figure out what the problem is, maybe post it here. It certainly sounds like webpack is using the Here's the PR where the change was made, out of interest: #306 |
I'm also using React Apollo in my universal app with Next.js and this is an issue for me as well -> adamsoffer/next-apollo-example#2 Could we include getDataFromTree in the browser build? Are there any drawbacks to this? |
Maybe this could be one motivation for creating a separate |
Cool. Well I can use |
@stubailo I realized I simply had to put In fact, I think my Next + React Apollo example is ready for showtime if you want to take a look 😄 I'm currently using graph.cool for my example but I can use apollostack/frontpage-server if we want to showcase an "official" hello world next+apollo example on the dev.apollo homepage. |
I started a second project with |
Long story short: I'm making a universal React app, so I've got an Express server to render the DOM. My page loads, but it doesn't seem likethis.props.data
gets populated until the client-side JS takes over.Is this intended? If so, is there a way to change it? If not, what may I be doing wrong? I can provide code if necessary, but there's a lot of it, so I'm not sure where to start.If it matters, I'm also mocking the server withgraphql-tools
, so the GraphQL "API" and the SSR are happening on the same express server.Edit: Poking around, it looks likethis.props.data.loading
istrue
on the server, so I assume that it's asynchronous and the HTML gets rendered before the response comes back. Is there a way to make it wait until it gets the data?Edit 2: I just noticed that the docs have a section on this! But for some reason, I'm getting this error:
Edit 3: Same issue with
renderToStringWithData
:Edit 4: I think I found the issue?
dist/index.js
doesn't export (or define)getDataFromTree
orrenderToStringWithData
. If I importnode_modules/react-apollo/lib/index
or ``node_modules/react-apollo/src/index`, it works.I can't figure out why
npm run compile:browser
doesn't put the exports intodist/index.js
. I'll keep digging around, but I don't know anything about Browserify or NPM packages 😰Edit 5: I no longer think that
dist/index.js
has anything to do with the issue, and it seems like even if I delete that andlib/index.js
, I can import everything that gets exported from thebrowser
module. I'm truly lost about what the problem is.The text was updated successfully, but these errors were encountered: