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

Add session argument for GraphQLApp() constructor #1297

Closed
wants to merge 1 commit into from

Conversation

conao3
Copy link

@conao3 conao3 commented Oct 3, 2021

  • Add session argument for GraphQLApp() constructor to allow
    specify sqlalchemy session.

see graphene doc.

Now we use this method,

Create a query for the models.

Base = declarative_base()
Base.query = db_session.query_property()

class MyModel(Base):
    # ...

but below method cannot use.

Set the db session when you do the execution:

schema = graphene.Schema()
schema.execute(context_value={'session': session})

This patch allows to use latter method like this.

schema = graphene.Schema(query=Query)
app = starlette.graphql.GraphQLApp(schema=schema, session={{your SA session}})

* Add session argument for GraphQLApp() constructor to allow
specify sqlalchemy session.
@Kludex
Copy link
Sponsor Member

Kludex commented Oct 3, 2021

GraphQL's support in Starlette will be removed in the next release (0.17.0). Check: #1198

@Kludex Kludex closed this Oct 3, 2021
@conao3 conao3 deleted the add-session-arg branch October 9, 2021 07:43
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

Successfully merging this pull request may close these issues.

None yet

2 participants