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.

'list' object has no attribute 'middlewares'

See original GitHub issue

The following code raises the above error.

def auth_middleware(resolver, obj, info, **kwargs):
    value = resolver(obj, info, **kwargs)
    return value

@graphql_api.route('/graphql', methods=["POST"])
def graphql_server():
    success, result = graphql_sync(
        schema,
        request.json,
        middleware=[auth_middleware]
    )

I think this is causing the issue: https://github.com/mirumee/ariadne/blob/2d2184939bf469f3a607bf3e08f2f27ca0fa7421/ariadne/extensions.py#L29-L30

Looks like the documentation isn’t up to date or wrong since this is expecting an MiddlewareManager but the documentation shows a plain list. Or am I getting something wrong here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
levrikcommented, Oct 10, 2019

Mhhh. So now I’m passing in MiddlewareManager([auth_middleware]) to graphql_sync, the error is gone but the middleware never gets called.

Edit: It looks like it has to be called like this, MiddlewareManager(auth_middleware, another_middleware, ...)

1reaction
rafalpcommented, Nov 29, 2022

I’ve decided to re-do middlewares starting with Ariadne 0.17. middlewares option will now be:

  • None
  • List of middlewares
  • A function returning None or list of middlewares

If you need custom middleware manager, it will be passable as middleware_manager_class option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'list' object has no attribute 'lower' in django - Stack Overflow
How to solve Exception Value: 'list' object has no attribute 'lower' in django - Stack Overflow. Stack Overflow for Teams – Start collaborating ......
Read more >
2567 (cache_page works as wrapper function, not as decorator)
Do you have any request-altering middleware in place? It looks like the request object is not a class instance, but a function instead,...
Read more >
Ansible dict object has no attribute stdout (or) stderr
This error appears when you are trying to iterate through a list or dictionary incorrectly. In this post, we will discuss how to...
Read more >
web3.py - AttributeError: 'list' object has no attribute 'sign'
AttributeError: 'list' object has no attribute 'sign'. Thanks: from web3 import Web3 from web3.middleware import geth_poa_middleware matic ...
Read more >
WSGIRequest' object has no attribute 'session'-django
If you came here because you updated to Django 2.0 and get this error, you might want to know that name MIDDLEWARE_CLASSES was...
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