Skip to content

Server rehydration cause first client query fail #759

@fikriauliya

Description

@fikriauliya

My app has main Redux store which Apollo attached to, with store rehydration and server side rendering.

When the page is first loaded (Server side rendering), apollo/queries/0 has the following initial value (which seems valid):

screen shot 2016-10-11 at 4 58 50 pm

The query is as follow ($page = 1):

apollo.query({
  variables: translatedQueries,
  query: gql`
    query Search($page:Int) {
      search(page: $page)
      {
        products {
          id
          name
        }
      }
    }
` })
.then(response => {console.log(response.data.search); response.data.search}

Problem

When the same query is run again on client but with different $page variable (i.e. move to 2nd page), apollo.query returns prematurely after APOLLO_QUERY_INIT but before APOLLO_QUERY_STOP and APOLLO_QUERY_RESULT. And the result printed from console.log above is wrong: the same as the one on the first page.

Moreover I think it's weird thatAPOLLO_QUERY_INIT modify apollo/queries/0/variables/page from 1 to 2 (shouldn't it just append new queries: apollo/queries/1 instead of updating the existing one?).
screen shot 2016-10-11 at 5 10 29 pm

More insight

Without refreshing the page, the same query is run again with even different $page variable (i.e. move to 3rd page). Now it prints correct result. Subsequent query also works correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions