Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Graphene usable by Newbies ... #1211

Open
ghost opened this issue Jun 24, 2020 · 4 comments
Open

Make Graphene usable by Newbies ... #1211

ghost opened this issue Jun 24, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Jun 24, 2020

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.

@ghost ghost added the ✨ enhancement label Jun 24, 2020
@jkimbo
Copy link
Member

jkimbo commented Jul 1, 2020

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.

@jkimbo jkimbo self-assigned this Jul 1, 2020
@austincollinpena
Copy link

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.

@austincollinpena
Copy link

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)))),
]

@jkimbo jkimbo removed their assignment Nov 4, 2020
@jkimbo
Copy link
Member

jkimbo commented Nov 4, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants