question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Usage with apollo

See original GitHub issue

Navi looks like a really neat little routing alternative. Our data always come from Apollo though which allows to fetch all data required in a whole react tree in server rendering with getDataFromTree is something like that possible with Navi?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

2reactions
MrLohcommented, Feb 22, 2019

@jamesknelson great, thanks for the explanation, I’m not sure when I will find time to try this out, as I’m on holiday in the next weeks, but I will let you know. If anyone want’s to try it in the the meantime, go ahead.

1reaction
jamesknelsoncommented, Feb 22, 2019

Thanks 😃

I just read through Apollo’s SSR docs now so I’m not an expert at this, but one approach would be to pass the client into Navi via context, and then use client.query() method within your Navi routes.

let routes = mount({
  '/:id': route(async (request, context) => {
    let result = await context.client.query({
      query: `graphql goes here`,
      variables: { id: request.params.id },
    })

    return {
      view: <MyScreen result={result} />
    }
  })
})

let app = <Router routes={routes} context={{ client }} />

You could then get the cache and put it in the generated HTML using a custom renderer, so that the fetched data is immediately available on the initial render.

This approach has the benefit that the next route won’t be shown until the query has resolved. And if you want to subscribe and watch the query, then you can still pass the query through to the component via prop.

(I don’t have much experience with Apollo so I’d love to hear if what I’m saying makes any sense)

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL On The Front-End (React And Apollo)
Usually, to handle GraphQL on the client-side, we make use of the Apollo Client. It allows developers to define, handle, and make queries/ ......
Read more >
Reviews, Pros & Cons | Companies using Apollo - StackShare
438 companies reportedly use Apollo in their tech stacks, including The New York Times, medium.com, and CircleCI. The New York Times. medium.com ...
Read more >
Apollo Client For Angular — Making Use of GraphQL - Medium
ApolloModule : This is the main module to make Apollo Client's features available in the Angular App; HttpLinkModule: Is used to fetch data...
Read more >
A complete introduction to Apollo, the GraphQL toolkit
Apollo is a suite of tools to create a GraphQL server, and to consume a GraphQL API. Let's explore Apollo in detail, both...
Read more >
How many UAD plug-ins can I run with my Apollo / UAD-2 ...
Note for Apollo Users: Apollo interfaces use DSP and memory resources for its internal mixer. Therefore, the UAD Meters will show some DSP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found