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

With Apollo GraphQL Example #950

Closed
wants to merge 6 commits into from
Closed

With Apollo GraphQL Example #950

wants to merge 6 commits into from

Conversation

rizalibnu
Copy link

Add an example of Razzle with Apollo GraphQL as requested on #509

This sample has the full SSR setup as described in the apollo graphql docs.

@rizalibnu rizalibnu changed the title With Apollo Graphql With Apollo GraphQL Mar 7, 2019
@rizalibnu rizalibnu changed the title With Apollo GraphQL With Apollo GraphQL Example Mar 7, 2019
@zifahm
Copy link

zifahm commented Mar 9, 2019

PR for apollo with typescript example #891
also readme has been updated.

link: createHttpLink({
uri: 'https://gql-placeholder.herokuapp.com/graphql',
}),
cache: new InMemoryCache(),
Copy link

Choose a reason for hiding this comment

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

Working from the Apollo docs (https://www.apollographql.com/docs/react/features/server-side-rendering#store-rehydration), you'll want to swap this out for

cache: new InMemoryCache().restore(window.__APOLLO_STATE__)

might also want to add

ssrForceFetchDelay: 100,
defaultOptions: {
  query: {
    fetchPolicy: 'cache-and-network',
  },
},

to avoid fetching data on the client-side that the server has already fetched.

// Pass your GraphQL endpoint to uri
const client = new ApolloClient({
link: createHttpLink({
uri: 'https://gql-placeholder.herokuapp.com/graphql',

Choose a reason for hiding this comment

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

This URL doesn't appear to be valid any longer when directly accessed. The following URL does work though: http://gql-placeholder.herokuapp.com/playground.

@fivethreeo fivethreeo closed this Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants