Open ghost opened 4 years ago
Thanks for the feedback @Pegase92 . I agree that documentation doesn’t do a good job of giving examples on how to solve issues that you might come across. I was thinking of setting up a “recipes” section in the documentation that can show more real world examples. Do you think that would help?
Regarding the issue you have here:
I have read what you mention about graphene.union... But it results at the end with an error (bad operator + for QuerySet)... And was not able to solve this problem.
Could you expand on it which maybe some code? It might be a good first example to put in the recipes section.
Project Structure: I think if there are any sample repos with a lot of queries/mutations that people want to share how they structured it would be very helpful.
Recipe, Custom Graphql Middleware. (This one adds a cookie). Code taken from Django Graphql JWT
from functools import wraps
import datetime
def custom_middleware(view_func):
@wraps(view_func)
def wrapped_view(request, *args, **kwargs):
request.custom_request = True
expires = datetime.datetime.now() + datetime.timedelta(seconds=1000000)
response = view_func(request, *args, **kwargs)
response.set_cookie('key',
'value',
expires=expires)
return response
return wrapped_view
And then in urls.py
from utils.middleware import custom_middleware
urlpatterns = [
url(r'^admin/', admin.site.urls),
path('graphql/', custom_middleware((GraphQLView.as_view(graphiql=True)))),
]
Unfortunately I no longer have the time to spend on this project so I'm not going to be able to resolve this issue. If anyone would like to get involved instead that would be great!
Good afternoon,
First of all I wish to sincerly thanks for all the work you have done to setup a so "big" project . I work now with python for more than 20 years. I have done a lot things with this langages , with library. I even teach python in University for early beginners. I am using graphene / graphene-mongo / Flask stack for an internal project. I really fight a lot to find answers within Graphene site or internet. Most of the time the examples given in your documentation are not "complete", meaning that I was not able to run them. For example I am looking for a way to make an Union between two requests. I have read what you mention about graphene.union... But it results at the end with an error (bad operator + for QuerySet)... And was not able to solve this problem.
Will it be possible to have a documentation that includes real and running examples with real problematics meet in industry. I will be very pleased to help you on that ... But I still have to improve may Graphene level !!
Have a nice day
B.