I am starting working on GraphQL and as I am from python background I am using GraphQL with Python.
I followed the steps provided here Link but I am still facing issues.
An error occurred while resolving field Query.hello
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 311, in resolve_or_error
return executor.execute(resolve_fn, source, info, **args)
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executors/sync.py", line 7, in execute
return fn(*args, **kwargs)
TypeError: resolve_hello() missing 2 required positional arguments: 'context' and 'info'
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 330, in complete_value_catching_error
exe_context, return_type, field_asts, info, result)
File "/usr/local/lib/python3.5/dist-packages/graphql/execution/executor.py", line 383, in complete_value
raise GraphQLLocatedError(field_asts, original_error=result)
graphql.error.located_error.GraphQLLocatedError: resolve_hello() missing 2 required positional arguments: 'context' and 'info'
None
Please, help me resolve the issue.
It looks like the graphQL documentation is out of date. Graphene-python 2 changed the method signature. Try something like this instead
def resolve_hello(self, info, **kwargs):
return 'Hello world!'
You are not giving much information here, maybe the code that triggers the error would be helpful, but googling I found some related posts
https://github.com/graphql-python/graphene/issues/601
https://github.com/graphql-python/graphene-django/issues/282
Maybe check the versions that you are using as they mention on the first link
Try to like this one concept example on date:
Graphql required positional arguments
info,and **kwarg
def resolve_generated_date(self, info, **kwargs):
created_date = self.created_at.strftime('%Y-%m-%d')
return created_date
Related
I've got a Flask application working like a charm in Python 3.7 but when I try to run it in Python 3.8, I get the following:
Traceback (most recent call last):
File "index.py", line 1410, in <module>
app.run(host='0.0.0.0', port='9000', extra_files=['config'])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/flask/app.py", line 990, in run
run_simple(host, port, self, **options)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/werkzeug/serving.py", line 1039, in run_simple
log_startup(s)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/werkzeug/serving.py", line 982, in log_startup
_log(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/werkzeug/_internal.py", line 113, in _log
getattr(_logger, type)(message.rstrip(), *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/logging/__init__.py", line 1434, in info
self._log(INFO, msg, args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/logging/__init__.py", line 1565, in _log
fn, lno, func, sinfo = self.findCaller(stack_info, stacklevel)
TypeError: findCaller() takes from 1 to 2 positional arguments but 3 were given
As I understand it, Flask and Werkzeug both support Python 3.8 and and so I'm confused as to why it seems as though Flask and Werkzeug seem to be causing this issue (they're both to up to date as well). Further, reading through the docs, the app.run method hasn't changed in recent versions (in a way that might explain this error).
Has anyone else encountered this issue?
A new argument called stacklevel was added in finCaller() function in Python 3.8. If you or the packages you use has rewritten the findCaller() with only two arguments. It will throw the error TypeError: findCaller() takes from 1 to 2 positional arguments but 3 were given.
To fix this, you will need to add the new argument to the findCaller function you have rewritten:
def findCaller(self, stack_info=False, stacklevel=1):
If the findCaller function that being rewritten is in other packages, you can submit an RP to fix it, just like these:
Fix TensorFlow on Python 3.8 logger issue #33953
fix for Python 3.8 BC breaking logging API change #126
Fix logger TypeError for Python 3.8 API change #14
When I try to call my custom django command with a id as a string it works without a problem.
call_command(COMMAND, '-i', '23')
But when I try to cast the id of a object to a string, then it will not work.
call_command(COMMAND, '-i', str(product.id))
It become this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/kombu/utils/__init__.py", line 423, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
Any idea why this is happening?
This function is inside a test, adding #override_settings(DEBUG=True) helped. The command is calling a task, so I had to made sure that it's not triggering the task.delay
Still strange that it worked with just putting the string as a parameter...
We are trying to use the method getPrivateNetworkVrfs() found in the doc
http://sldn.softlayer.com/reference/services/SoftLayer_Account. But we are getting error like
client.call('SoftLayer_Account', 'getPrivateNetworkVrfs')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/SoftLayer/API.py", line 237, in call
return self.transport(request)
File "/usr/local/lib/python2.7/site-packages/SoftLayer/transports.py", line 187, in __call__
raise _ex(ex.faultCode, ex.faultString)
SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(Client): Function ("getPrivateNetworkVrfs") is not a valid method for this service.
But we are able to use method like "getNetworkVlanSpan" successfully
Please let us know, whether we are missing anything here?
Thanks
Unfortunately, the SoftLayer_Account::getPrivateNetworkVrfs method is deprecated, if you would like to check or get this kind of information, you need to submit a ticket
Related Forum:
Is there an API to check whether an account has VRF or not?
This code executes with error:
# some constants and auth before, looks not important
topPosts = reddit.get_subreddit('funny').get_top(limit=3)
for post in topPosts:
twitter.PostUpdate(status = post.title, media = post.url)
Console log:
Traceback (most recent call last):
File "script.py", line 17, in <module>
twitter.PostUpdate(status = post.title, media = post.url)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twitter/api.py", line 990, in PostUpdate
media_additional_owners)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twitter/api.py", line 1132, in UploadMediaChunked
boundary = bytes("--{0}".format(uuid4()), 'utf-8')
TypeError: str() takes at most 1 argument (2 given)
If I do just post.label in loop it works perfectly.
If I execute only one (w/o loop) PostUpdate it works perfectly.
I think it's happening because PostUpdate is asynchronous, but can't figure out how to fix it. Please help.
This is a bug in python-twitter library and it's fixed in this PR. The problem is that bytes in python2 equals to str and accepts only one argument while in python3 bytes requires encoding as a second argument.
I'm testing a django project using the test sever when it gives me the following exception
Traceback (most recent call last):
File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 280, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/pymodules/python2.6/django/core/servers/basehttp.py", line 674, in >call
return self.application(environ, start_response)
File "/usr/lib/pymodules/python2.6/django/core/handlers/wsgi.py", line 245, in call
response = middleware_method(request, response)
File "/usr/lib/pymodules/python2.6/django/middleware/common.py", line 84, in >process_response
if response.status_code == 404:
AttributeError: 'search' object has no attribute 'status_code'
Just from reading this traceback, I don't think the problem is in my code, but I'm not sure. Could someone look through my code and help me solve this problem? my code is hosted on GitHub and any other comments or suggestions are greatly appreciated. Thanks in advance for your time and consideration.
MusicGrep/musicgrep/views.py is not returning a HttpResponse instance
There are quite a few problems with your code, but the one that's causing the actual error you quote is that you don't instantiate your FormWizard subclass in your urlconf.
As the documentation shows, you need to actually call the search class in urls.py to instantiate it, so you pass an instance rather than a class.
(r'^MusicGrep/$', 'MusicGrep.musicgrep.forms.search()'),
It might help if you followed the PEP8 guidelines on naming - if your class was called Search with a capital S, it would be more obvious that it was actually a class and not a function.