Skip to content

Add session argument for GraphQLApp() constructor#1297

Closed
conao3 wants to merge 1 commit intoKludex:masterfrom
conao3:add-session-arg
Closed

Add session argument for GraphQLApp() constructor#1297
conao3 wants to merge 1 commit intoKludex:masterfrom
conao3:add-session-arg

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
Owner

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.

2 participants