React / Apollo: Displaying Error of GraphQL mutation (useMutation hook) - python

I am having a hard time trying to figure out why I can't show the error of my mutation.
I have implemented error codes in my mutation:
if location_lat < 0.1 and location_lon < 0.1:
raise GraphQLError('E_CF_002')
now on the client-side, I call the following mutation, which is called onSubmit of a form and I purposefully trigger the error.
const [
createEvent,
{ data: createData, loading: createLoading, error: createError}
] = useMutation(CREATE_EVENT);
The error code is successfully returned as seen in my network tab:
{"errors": [{"message": "E_CF_002", "locations": [{"line":
However, when I try to show the error in a dialogue box
{createError && (
<div>
<Dialog open={openDialog} onClose={handleClose}>
<h3>Sorry, an error occured while creating the event.</h3>
<h3>Plese try again later. {JSON.stringify(createError)} </h3>
<DialogActions>
<Button onClick={handleClose} color="primary">
Okay
</Button>
</DialogActions>
</Dialog>
</div>
)}
I only see:
Sorry, an error occured while creating the event.
Plese try again later. {}
Can anyone help me understand why my error variable does not hold the message etc.?
I first tried directly printing createError.message or createError[0].message or even createError.errors and even createError.errors[0] however later on I saw that even the entire JSON is empty by printing JSON.stringify(createError).
I haven't been able to find this specific issue (or it's solution) on StackOverflow or elsewhere.
Thank you in advance!

Related

jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'type'

Trying to execute python function in HTML but receiving the following error:
ERROR
jinja2.exceptions.TemplateSyntaxError
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'type'.
CODE
<p>Hi, this is a para {{ type(res) }}</p>
CODE EXPLANATION
It just a para that is receiving res dictionary and displaying here. When I am trying to display the whole dictionary it runs well, when displaying a specific value of dictionary it displays nothing, and when finding the type of variable it shows an error.
You can return it as a variable with flask.
return render_template('template.html',res_type=type(res))
and in HTML:
<p>Out:{{res_type}}</p>

Why does createNote on Evernote Python API fail with errorcode 5 (DATA_REQUIRED) though data seems to be provided?

I'm new to the Evernote python 2.x API and I'm working on some examples. I managed to create a note in the sandbox, but I failed in creating a note with attachment. I followed the example code given in https://dev.evernote.com/doc/articles/creating_notes.php and I end up calling
try:
note = noteStore.createNote(authToken, ourNote)
except Errors.EDAMUserException, edue:
## Something was wrong with the note data
## See EDAMErrorCode enumeration for error code explanation
## http://dev.evernote.com/documentation/reference/Errors.html#Enum_EDAMErrorCode
print "EDAMUserException:", edue
return None
The parameter ourNote was printed as
Note(contentHash=None, updated=None, created=None, deleted=None, contentLength=None, title='testtitel2', notebookGuid=None, content='<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd"><en-note>testbody<br /><br />Attachment with hash 3430623163666630303562663662393263386539663366613134636630323736: <br /><en-media type="text/plain" hash="3430623163666630303562663662393263386539663366613134636630323736" /><br /></en-note>', tagNames=None, updateSequenceNum=None, tagGuids=None, active=None, attributes=None, guid=None, resources=[Resource(noteGuid=None, height=None, width=None, alternateData=None, mime='text/plain', updateSequenceNum=None, duration=None, attributes=ResourceAttributes(recoType=None, sourceURL=None, cameraMake=None, timestamp=None, altitude=None, clientWillIndex=None, longitude=None, fileName=None, attachment=None, latitude=None, applicationData=None, cameraModel=None), guid=None, data=Data(body='This is the content of testfile, aaa, bbb\\n\n', bodyHash='40b1cff005bf6b92c8e9f3fa14cf0276', size=44), active=None, recognition=None)])
I'm getting
EDAMUserException: EDAMUserException(errorCode=5, parameter='[3430623163666630303562663662393263386539663366613134636630323736]')
which says DATA_REQUIRED. What exactly is wrong or missing?
From the error message, you are missing a resource that is in your ENML. See this sample code to make sure you are handling your file attached to your note properly.
I resolved my issue by changing line 20 in the sample code from
hexhash = binascii.hexlify(resource.data.bodyHash)
to
hexhash = resource.data.bodyHash
which makes it work. I don't know what the hexlify() was intended for here. I will ask the Evernote guys. The parameter in the error message in my original post was the "hexlified" hash. Btw: in order to determine the bodyHash I'm using the way described here.

how to get the value of a single object?

I'm doing a presentation of the sample model (Footer.objects.all()) and send the result to the template. deduce the template through the cycle for:
{% for entrie in copyright_obj%}
     {{entrie.copyright}}
{% endfor%}
The resulting data are displayed on the screen
but if I do so sample Footer.objects.all()[0], I get a message on the screen error
Exception Type: TypeError
Exception Value:
'Footer' object is not iterable
please tell me how can I print the data in this case?
The statement
Footer.objects.all()[0]
don't have any problem.
The thing is you're using the same template and you're trying to iterate over a single Footer objet.

Django - Else Syntax Error

I have the following code on my views.py
def visao_produto(request, produto_visualizado, categoria_produto):
produto = Camisa.objects.get(slug=produto_visualizado)
categoria_desejada = categoria_produto.replace("_"," ")
if request.method == 'POST':
form = LojaForm(request.POST)
if form.is_valid():
add_to_cart(request, produto_visualizado.id, produto_visualizado.tipo, produto_visualizado.categoria)
get_cart(request)
else:
print form.errors
else:
form = LojaForm()
return render_to_response('loja/produto_visualizado.html', { 'produto' : produto, 'categoria_desejada' : categoria_desejada, 'form' : form }, context_instance = RequestContext(request))
But my template is returning the following error:
SyntaxError at /loja/Minecraft/minecraftsteve/
invalid syntax (views.py, line 34)
Line 34, on this case, is the line of the last else, before "print form.errors", which is there because i was trying to solve this problem. I'm not sure if the rest of the code is correct, but right now i'm just stuck on this problem.
I have imported everything and i really don't know what is possible to be wrong in an else statement.
Thanks for your help
Indentation error is my best guess, right above the else line in question. Django sometimes spits these out as simple syntax issues. Immediate other things to check (that don't seem present) are a missed closing quote, comma or parentheses, though I really don't see any of those (which leads me to indent errors).
I've gone over your code and even copied/pasted with some dummy stuff into my test server, and I can't find anything "wrong" with what shows up here on screen. So I'd start by making sure there's not an issue where you used 4 spaces instead of tab or vice versa. That would be covered up by Stack's HTML formatting so we can't necessarily see that.

why are there =\r\n characters coming from my textarea?

In my form i have:
<textarea id="styled" name="content"></textarea>
before submitting the form i cut and paste the following into the text area:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
When I retrieve the value on google app engine:
ImageUploadHandler(blobstore_handlers.BlobstoreUploadHandler):
content_i = self.request.get("content", None)
#content_i is:
u'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa=\r\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
This is because of this bug. Though this might solve your problem -> #AndreBrossards Middleware Fix

Categories

Resources