Saleor: Upgrade graphene-django to 2.7.0 and above (filters connection)

Created on 9 Dec 2019  路  6Comments  路  Source: mirumee/saleor

Blamed breaking changes: https://github.com/graphql-python/graphene-django/compare/v2.6.0...v2.7.0#diff-4693e93918b75fd2ff08fbe53fec5118R141

What I'm trying to achieve

When I run the environment I can't run some graphql queries.

Steps to reproduce the problem

  1. Build and configure an environment (migrations synced, populatedb synced)
  2. Run a products graphQL

System information
Operating system: macOs Mojave 10.14.6

Environment: Python 3.8.0 OR Docker Image (both result on same error)

After the latest updates (I am synchronized with the last head of the master branch # 440c9b18fce96a14827a59ec1c4c659c0fdf1a09) when I run a basic graphql query on products, eg:

query {
  products(first: 3) {
    edges {
      node {
        id
        name
        description
        category {
          name
        }
      }
    }
  }
}

I got the following error:

{
    "errors": [
        {
            "message": "connection_resolver() takes 10 positional arguments but 11 were given",
            "locations": [
                {
                    "line": 2,
                    "column": 3
                }
            ],
            "path": [
                "products"
            ],
            "extensions": {
                "exception": {
                    "code": "TypeError",
                    "stacktrace": [
                        "Traceback (most recent call last):",
                        "  File \"/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.8/lib/python3.8/site-packages/promise/promise.py\", line 487, in _resolve_from_executor",
                        "    executor(resolve, reject)",
                        "  File \"/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.8/lib/python3.8/site-packages/promise/promise.py\", line 754, in executor",
                        "    return resolve(f(*args, **kwargs))",
                        "  File \"/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.8/lib/python3.8/site-packages/graphql/execution/middleware.py\", line 75, in make_it_promise",
                        "    return next(*args, **kwargs)",
                        "TypeError: connection_resolver() takes 10 positional arguments but 11 were given"
                    ]
                }
            }
        }
    ],
    "data": {
        "products": null
    }
}

The same occurs on query productVariants, but if i try:

query {
  product(id: "UHJvZHVjdDo2MQ==") {
    id
    name
    description
    category {
      name
    }
  }
}

I got the correct result:

{
    "data": {
        "product": {
            "id": "UHJvZHVjdDo2MQ==",
            "name": "Nebula Night Sky Paint",
            "description": "Tonight, my love, let us take fat brushes and paint the skies with the shades of nebula tides. Get the dark, moody shades of the ether.",
            "category": {
                "name": "Accessories"
            }
        }
    }
}

Is this problem only related to my environment? I've been testing for some time and I had no problem like that ...

I also did an extensive search on the repository's issues base and also tried hard to find something related to graphene, but as it is a bit generic error I found nothing that could help me.

In addition I rolled back to python version 3.7.4 and tested to see if it was anything to do with it (since the update to version 3.8.0 is recent) but the same error happened in version 3.7.

I had a bit of trouble debugging the connection_resolver method arguments, so I'm opening here .. hope you can help me! I apologize if I was not very clear.

Thanks guys

blocker

Most helpful comment

You need to stay to graphene-django 2.6.0 for now. You probably added dependencies or manually updated your poetry lock file, which upgraded to graphene-django 2.7.x, I just tried and it does break. If it bothers/blocks you, you can temporarily lock the dependency to 2.6.0 in your pyproject.toml (changing graphene-django = "^2.4" to graphene-django = "^2.6.0") while waiting for an update.

I will patch it tomorrow if nobody took it in the meantime (and if I have a few spare minutes).

Thanks for the finding :)

All 6 comments

Hi @daltonsena,
I wasn't able to reproduce this issue (on Mojave and Py3.7).
Can you share some details from the server logs (with exception)?
Did you try to reinstall requirements?

Hi @korycins,

Thank you for your help!

Yes! I was actually in python version 3.8.0, after this I created a new environment for 3.7.0 (in this step I installed all the requirements from the beginning - via poetry -)

this is the server log when the issue occurs:

INFO celery.app.trace Task saleor.core.analytics.ga_report[e6ef72e6-4427-43f0-bbbe-d450581ac791] succeeded in 0.26158932398539037s: None [PID:14699:Thread-215]
ERROR graphql.execution.executor An error occurred while resolving field Query.products [PID:14699:Thread-215]
Traceback (most recent call last):
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executor.py", line 450, in resolve_or_error
    return executor.execute(resolve_fn, source, info, **args)
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executors/sync.py", line 16, in execute
    return fn(*args, **kwargs)
TypeError: connection_resolver() takes 10 positional arguments but 11 were given
ERROR graphql.execution.utils Traceback (most recent call last):
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executor.py", line 450, in resolve_or_error
    return executor.execute(resolve_fn, source, info, **args)
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executors/sync.py", line 16, in execute
    return fn(*args, **kwargs)
graphql.error.located_error.GraphQLLocatedError: connection_resolver() takes 10 positional arguments but 11 were given
 [PID:14699:Thread-215]
ERROR saleor.graphql.errors.unhandled A query failed unexpectedly [PID:14699:Thread-215]
Traceback (most recent call last):
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executor.py", line 450, in resolve_or_error
    return executor.execute(resolve_fn, source, info, **args)
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executors/sync.py", line 16, in execute
    return fn(*args, **kwargs)
TypeError: connection_resolver() takes 10 positional arguments but 11 were given
ERROR saleor.graphql.errors.unhandled A query failed unexpectedly [PID:14699:Thread-215]
Traceback (most recent call last):
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executor.py", line 450, in resolve_or_error
    return executor.execute(resolve_fn, source, info, **args)
  File "/Users/u/Library/Caches/pypoetry/virtualenvs/saleor-py3.7/lib/python3.7/site-packages/graphql/execution/executors/sync.py", line 16, in execute
    return fn(*args, **kwargs)
TypeError: connection_resolver() takes 10 positional arguments but 11 were given
INFO django.server "POST /graphql/ HTTP/1.1" 200 816 [PID:14699:Thread-215]
INFO django.server "POST /graphql/ HTTP/1.1" 200 816 [PID:14699:Thread-215]
INFO django.server "POST /graphql/ HTTP/1.1" 200 816 [PID:14699:Thread-215]

@daltonsena Do you have the same issue with clean env and pip install -r requirements.txt;pip install -r requirements_dev.txt

@korycins it worked! I started a new virtualenv and instaled from requirements_*.txt..

Now the return seems ok:

# Write your query or mutation here
query {
  products(first: 3) {
    edges {
      node {
        id
        name
        description
        category {
          name
        }
      }
    }
  }
}
{
  "data": {
    "products": {
      "edges": [
        {
          "node": {
            "id": "UHJvZHVjdDo3Mg==",
            "name": "Apple Juice",
            "description": "Fell straight from the tree, on to Newton鈥檚 head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",
            "category": {
              "name": "Juices"
            }
          }
        },
        {
          "node": {
            "id": "UHJvZHVjdDo3NA==",
            "name": "Banana Juice",
            "description": "Build your protein the natural way, with exotic banana juice made from ripe fruit and packed with all the goodness of the tropical sun.",
            "category": {
              "name": "Juices"
            }
          }
        },
        {
          "node": {
            "id": "UHJvZHVjdDo3OQ==",
            "name": "Bean Juice",
            "description": "Bean there, drunk that! The energy drink for the health-conscious. Brand new bean juice; from allotment to bottle in under 8 hours.",
            "category": {
              "name": "Juices"
            }
          }
        }
      ]
    }
  }
}

What is your suggestion for how I proceed with this issue?

You need to stay to graphene-django 2.6.0 for now. You probably added dependencies or manually updated your poetry lock file, which upgraded to graphene-django 2.7.x, I just tried and it does break. If it bothers/blocks you, you can temporarily lock the dependency to 2.6.0 in your pyproject.toml (changing graphene-django = "^2.4" to graphene-django = "^2.6.0") while waiting for an update.

I will patch it tomorrow if nobody took it in the meantime (and if I have a few spare minutes).

Thanks for the finding :)

Thank you! This project is wonderful, I love it!

Sorry for not being able to figure out the lock issue in the dependency.

I'm still starting with graphene, I need to read the documentation a bit more, so don't risk making this patch ... thanks!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tanvirraj picture tanvirraj  路  3Comments

Pacu2 picture Pacu2  路  4Comments

NumanIjaz picture NumanIjaz  路  3Comments

maltitco picture maltitco  路  3Comments

flaviocolonna picture flaviocolonna  路  3Comments