Skip to content

Feedback for “Server Side Rendering” #2050

@chriswoodie

Description

@chriswoodie

I don't understand this block. At no point am I manually calling Apollo.create, nor does https://the-guild.dev/graphql/apollo-angular/docs/get-started mention anything about this, despite this block referring to it.

You saw how to use Server-Side Rendering and Store Rehydration in your application, but you will need to be a little careful in how you create Apollo on the server to ensure everything works there as well:
When creating Apollo (Apollo.create) on the server, you'll need to set up your HttpLink to connect to the API server correctly. This might look different to how you do it on the client, since you'll probably have to use an absolute URL to the server if you were using a relative URL on the client.
Since you only want to fetch each query result once, pass the ssrMode: true option to the Apollo.create to avoid repeated force-fetching.
You need to ensure that you create a new client or store instance for each request, rather than re-using the same client for multiple requests. Otherwise, the UI will be getting stale data, and you'll have problems with authentication.

Can you clarify if this is still relevant and if so, what exactly do you have to do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions