-
Notifications
You must be signed in to change notification settings - Fork 3
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
SQLAlchemy implementation #1
Comments
I haven't worked with Graphene-SQLAlchemy myself, but it looks to me like you could create your schema the same way you usually would and then use that. To copy from Graphene-SQLAlchemy's first example, you could try something like this: Base = declarative_base()
class UserModel(Base):
__tablename__ = 'department'
id = Column(Integer, primary_key=True)
name = Column(String)
last_name = Column(String)
class User(SQLAlchemyObjectType):
class Meta:
model = UserModel
# Define a GraphQL query schema.
class Query(graphene.ObjectType):
users = graphene.List(User)
def resolve_users(self, info):
query = User.get_query(info) # SQLAlchemy query
return query.all()
# Create the schema that will be used to resolve GraphQL requests.
schema = graphene.Schema(query=Query) The main other thing that you may need to add is to pass in your db handler via context when calling |
I think that's where my primary hangup was, namely passing the SQLAlchemy Further tinkering and http://docs.graphene-python.org/projects/sqlalchemy/en/latest/tips/#querying makes me think that there are three options here.:
Thanks a lot for the code again! Any plans to make it into a |
Hi there and thanks a lot for posting this :). Would you happen to have figured out how to glue together Graphene, Graphene-SQLAlchemy, and Falcon?
The text was updated successfully, but these errors were encountered: