Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable SSR for specific queries #32

Closed
fabienheureux opened this issue Mar 20, 2019 · 1 comment
Closed

Disable SSR for specific queries #32

fabienheureux opened this issue Mar 20, 2019 · 1 comment

Comments

@fabienheureux
Copy link

Hey, do you think it could be relevant to add an option to disable a query to run on the server ?

I have a use case where I want the nextjs app to load first, and dont wait for all queries to run.
An option to force some specifically slow queries to run on the client-only could help.

Tell me if it you need more information / an example repo to explain my use case.

@jaydenseric jaydenseric transferred this issue from jaydenseric/next-graphql-react Mar 20, 2019
@jaydenseric
Copy link
Owner

I had considered this feature before, and decided against it.

A slow loading page is not as bad as having holes in the server side rendered content that affect SEO, etc. The best fix is to improve the speed of the slow queries; there is almost always something that can be done about it and a slow query on the client is still a problem to be fixed anyway.

In the meantime you should be able to skip SSR by setting loadOnMount to false, and calling load() manually on mount via a useEffect hook. Something like this:

const { load } = useGraphQL({
  loadOnMount: false,
  // Other options…
})

useEffect(() => {
  load()
}, [load])

I just free-handed that code, so I may have overlooked something 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants