Search code examples
relayjsrelay

Relay Modern- Object passed into QueryRenderer as variable breaks when edited with RefetchContainer


Passing an object into QueryRenderer variable. In the refetch container rendered on success, when anything changes in the object, the container breaks. Also passing an integer as a variable that doesn't break on change via refetch.

i.e.-

<QueryRenderer
  query={query}
  variables={
    count: 5, 
    testObject= { 
      something1: { 
        something2: ['something', 'something'] 
      }
    }
  ...
 />

 Refetch container calls via 
 _onRefetch() => {
     const newSearch = {
       something1: {
         something2: ['somethingElse'],
       }
    };
    const refetchVariables = fragmentVariables => ({
      testObject: newSearch,
      count: this.state.currentCount + 10,
    });
   nullthrows(this.props.relay).refetch(
    refetchVariables,
    null);
 }

Does relay modern refetch not handle objects, or is there something I'm doing wrong?


Solution

  • Ended up needing to rerender the QR from a parent component when the query level variables changed.