Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

New variables are not used after refetch(newVars) #37

Closed
jbaxleyiii opened this issue Nov 13, 2017 · 2 comments
Closed

New variables are not used after refetch(newVars) #37

jbaxleyiii opened this issue Nov 13, 2017 · 2 comments

Comments

@jbaxleyiii
Copy link
Contributor

Hello! I don't know how to make it better. Please help.
I use the function:

    async update() {
        let variables = {
            company: this.props.match.params.companyId,
            filter: this.filter, order: this.order, limit: this.pagiation.limit, offset: this.pagiation.offset
        };
        await this.props.refetch(variables);
    }

But I see in Network two queries and nothing happens.
The first one is right, but the second is the default data (like variables: { company: props.match.params.companyId, filter: {}, order: [], limit: 10, offset: 0 }). Why?

@ApolloReact.graphql(ApolloReact.gql"
    query Departments($company: ID!, $filter: DepartmentFilter!, $order: [DepartmentOrder], $limit: Int, $offset: Int) {
        company {
            get(id: $company) {
                id,
                name,
                color,
                departments {
                    list(filter: $filter, order: $order, limit: $limit, offset: $offset) {
                        departments {
                            id,
                            color,
                            name,
                            users {
                                id, avatar, username
                            },
                            tags {
                                name
                            },
                            date
                        },
                        count
                    }
                }
            }
        }
    }", {
    props: ({ ownProps, data: { loading, company, refetch } }) => ({
        company: company && company.get,
        departments: company && company.get && company.get.departments && company.get.departments.list.departments,
        count: company && company.get && company.get.departments && company.get.departments.list.count,
        loading: loading,
        refetch: refetch
    }),
    options: (props) => ({
        fetchPolicy: 'cache-and-network',
        variables: { company: props.match.params.companyId, filter: {}, order: [], limit: 10, offset: 0 }
    }),
})

But if I call console.log(await this.props.refetch(variables)); this is what I need, but I want to see it in props.

    async update() {
        let variables = {
            company: this.props.match.params.companyId,
            filter: this.filter, order: this.order, limit: this.pagiation.limit, offset: this.pagiation.offset
        };
        console.log(await this.props.refetch(variables));
    }
@jbaxleyiii
Copy link
Contributor Author

➤ stale[bot] commented:

This issue has been automatically labled because it has not had recent activity. If you have not received a response from anyone, please mention the repository maintainer (most likely @jbaxleyiii). It will be closed if no further activity occurs. Thank you for your contributions to React Apollo!

@jbaxleyiii
Copy link
Contributor Author

➤ Makame commented:

It still doesn't work. I think you have too many stars.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant