Skip to content

Compatibility with fetchQuery #25

@wasd171

Description

@wasd171

Hi!

I think that this library might not be 100% compatible with a fetchQuery.
Imagine the following setup:

  • There are 2 pages, PageA and PageB which have a QueryA and QueryB connected to them respectively.
  • We are using relay-query-lookup-renderer only to read from the Relay store, data fetching is done independently via fetchQuery.

The user journey is:

  1. Visits PageA. QueryA is fetched on the server, Relay store records are used to hydrate the store on the client. QueryLookupRenderer reads the data from Relay store by being rendered with query={QueryA} and render={({props}) => <ComponentA data={props}/>}
  2. Travels from PageA to PageB.
  • QueryB is fetched via the fetchQuery
  • QueryLookupRenderer is re-rendered with query={QueryB} and render={({props}) => <ComponentB data={props}/>}, data is already in the store
  1. Travels from PageB to PageA
  • QueryA is fetched via the fetchQuery
  • Possible bug - before QueryLookupRenderer is re-rendered with query={QueryA} it actually invokes the render function with props corresponding to QueryA, even though the render itself is still ({props}) => <ComponentB data={props}/> and the query prop is still QueryB
  • QueryLookupRenderer is re-rendered with query={QueryA} and render={({props}) => <ComponentA data={props}/>}

I suppose that it has to do something with QueryA already being present in the Relay store. Recreating a store on every page transition fixes it.

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