relay refetch doesn't show the result
Asked Answered
B

0

3

I'm trying to create a live search-result component(lazy load one). It works perfectly for the first time but refetch doesn't update the data. I see the request and respoonse in Network tab! so it does get the data, but it doesn't supply it to the component!

any idea why?

import React, { Component } from 'react';
import {
    createRefetchContainer,
    graphql,
} from 'react-relay';

import ProfileShow from './ProfileShow';

class ProfileList extends Component {
    render() {
        console.log("rendering....", this.props)
        return (
            <div className="row">
                <input type="text" onClick={this._loadMe.bind(this)} />
                {this.props.persons.map((person) => {
                    return (
                        <div className="col-md-3">
                            <ProfileShow person={person} />
                        </div>
                    );
                })}

            </div>
        );
    }
    _loadMe(e) {
        const refetchVariables = fragmentVariables => ({
            queryStr: e.target.value,
        });

        this.props.relay.refetch(refetchVariables, null, (...data) => {
            console.log(data)
        });
    }
}

const FragmentContainer = createRefetchContainer(
    ProfileList,
    {
        persons: graphql.experimental`
        fragment ProfileList_persons on Person @relay(plural: true) {
            fullname
            number
            email
            pic
        }
    `
    },
    graphql.experimental`
    query ProfileListRefetchQuery($queryStr: String!) {
        talentList(query: $queryStr) {
        ...ProfileList_persons
        }
    }
  `,
);

export default FragmentContainer;
Betterment answered 18/7, 2017 at 8:6 Comment(4)
So I didnt had enough time to spent on this issue! Instead I used Apollo Client which was perfect!Betterment
I'm having the same issueWeekday
Use Apollo Client! it's way easier to use and has more useful features!Betterment
I actually did, it's superior in every way. thanks!Weekday

© 2022 - 2024 — McMap. All rights reserved.