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

Using Flask_Cognito with add_url_rule() #5

Open
laayis opened this issue May 29, 2019 · 3 comments
Open

Using Flask_Cognito with add_url_rule() #5

laayis opened this issue May 29, 2019 · 3 comments

Comments

@laayis
Copy link

laayis commented May 29, 2019

Hi am very new to flask. How can one use this library with the add_url_rule() method for authentication?

app.add_url_rule(
'/example', #the endpoint
view_func=GraphQLView.as_view( #setting the view function
'lta',
#we set the schema that we generate
schema=schema,
#we say that we do want to use graphqli interface
graphiql=True))

@revmischa
Copy link
Member

I'm not positive but maybe try view_func= cognito_auth_required(GraphQLView.as_view( ...

@revmischa
Copy link
Member

a decorator is just a function that takes a function and returns a function

@cdominguezg
Copy link
Contributor

cdominguezg commented Jun 24, 2020

Yes, you can do as @revmischa says. I've done something like this but in a separate function:

def graphql_view():
    view = GraphQLView.as_view('graphql', schema=schema, graphiql=True)
    return cognito_auth_required(view)

app.add_url_rule('/graphql', view_func=graphql_view())

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

No branches or pull requests

3 participants