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

(next-urql) Expose initUrqlClient function for manual usage in Next’s getServerSideProps methods #993

Merged
merged 8 commits into from
Sep 22, 2020

Conversation

sunpietro
Copy link
Contributor

Summary

Expose initUrqlClient function in order to allow fetching data in SSR mode. Without it data can be fetched only in client-side rendered apps and in static pages.

Set of changes

  • Exposed initUrqlClient function in the packages/next-urql/src/index.ts file.
  • Added a sample implementation demo (based on 1-with-urql-client demo)

Notes: The GraphQL server doesn't work, I had to use different ones in order to test the functionality. I kept the old Pokemon endpoints for consistency.

@changeset-bot
Copy link

changeset-bot bot commented Sep 20, 2020

🦋 Changeset is good to go

Latest commit: 582c83f

We got this.

This PR includes changesets to release 1 package
Name Type
next-urql Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sunpietro sunpietro force-pushed the expose-init-client branch 3 times, most recently from ed0a166 to 65a4fa9 Compare September 20, 2020 11:21
@kitten
Copy link
Member

kitten commented Sep 21, 2020

I'd love to get this merged, however can you remove the example from this PR for now please? A small addition like this is probably better for our documentation which I can take care of once this is merged and it's a lot of added example code to maintain for us (and also mostly duplicate) for a small additional API.

On another note, can you please add a changeset? There's a guide on how to do this here, but I'm also happy to help if you run into any trouble 🙌 https://github.com/FormidableLabs/urql/blob/main/CONTRIBUTING.md#how-do-i-document-a-change-for-the-changelog

@sunpietro
Copy link
Contributor Author

@kitten I've added changeset and missing docs. As well as I removed the example from PR.

@sunpietro sunpietro changed the title Expose initUrqlClient in order to allow fetching data in SSR mode Expose initUrqlClient in order to allow fetching data on server while rendering pages in NextJS Sep 22, 2020
…ly for use in Next's newer SSR methods manually, such as getServerSideProps
@sunpietro sunpietro changed the title Expose initUrqlClient in order to allow fetching data on server while rendering pages in NextJS Expose initUrqlClient function so that a Client can be created manually for use in Next's newer SSR methods manually, such as getServerSideProps Sep 22, 2020
@sunpietro
Copy link
Contributor Author

@kitten and @parkerziegler thanks for all your comments. I've updated PR with the latest requirements (fixing the changeset and renaming the commit and PR titles)

@parkerziegler
Copy link
Contributor

Last few grammatical and typo fixes, then we're good to go. Thanks @sunpietro!

@sunpietro
Copy link
Contributor Author

@parkerziegler thank you for your kind review. All your suggestions have been just applied :)

Copy link
Member

@kitten kitten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for that bit of back and forth! Let's get this in 🙌

Copy link
Contributor

@parkerziegler parkerziegler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 @kitten you wanna do the honors?

@kitten kitten changed the title Expose initUrqlClient function so that a Client can be created manually for use in Next's newer SSR methods manually, such as getServerSideProps (next-urql) Expose initUrqlClient function for manual usage in Next’s getServerSideProps methods Sep 22, 2020
@kitten kitten merged commit 0958553 into urql-graphql:main Sep 22, 2020
@sunpietro
Copy link
Contributor Author

Thank you :)

@sunpietro sunpietro deleted the expose-init-client branch September 23, 2020 05:59
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

Successfully merging this pull request may close these issues.

3 participants