question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New variables are not used after refetch(newVars)

See original GitHub issue

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 }
    }),
})

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:42 (7 by maintainers)

github_iconTop GitHub Comments

37reactions
jbaxleyiiicommented, Jul 9, 2019

@joebernard Thanks for reporting this. There hasn’t been any activity here in quite some time, so we’ll close this issue for now. Can you open a new issue reporting your issues with a reproduction for us to take a look into?

10reactions
pl12133commented, Jul 10, 2019

I have updated the versions of apollo-client and other packages in the reproduction and this bug is still present.

Please see https://codesandbox.io/s/j3410pq2vv

  "dependencies": {
    "apollo-cache-inmemory": "1.6.2",
    "apollo-client": "2.6.3",
    "apollo-link-http": "1.5.15",
    "graphql": "14.4.2",
    "graphql-tag": "2.10.1",
    "react": "15.6.1",
    "react-apollo": "2.5.8",
    "react-dom": "15.6.1"
  }

@jbaxleyiii Could we revisit the original issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refetch not working with new variables - Help - Apollo GraphQL
Hey all, I'm using apollo-client and am experiencing a problem where I am trying to refetch some data with new variables and it...
Read more >
Apollo useLazyQuery hook uses old variables when ...
I'm really stumped. It seems like the docs say new variables are supposed to be used if they are provided on refetch. I...
Read more >
Chapter 5 Data Manipulation | Introduction to Stata
5.2 Generating new variables. The generate command can be used to create new variables which are functions of existing variables. For example, if...
Read more >
18 Programming Stata
After all, you do not need to know how to program Stata to import data, create new variables, and fit ... 2. do...
Read more >
indigo_2021.1_documentation:variable_class [Indigo Domotics]
folderId, integer, the unique id of the folder this variable is in (0 if it's not in a folder) - use moveToFolder() method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found