Last active
May 1, 2018 14:43
-
-
Save ssomnoremac/ccd5ccc84307a8dc06784c50eb1158c8 to your computer and use it in GitHub Desktop.
schema.py for graphene and sqlalchemy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import graphene | |
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType | |
from models import * | |
class Person(SQLAlchemyObjectType): | |
class Meta: | |
model = PersonModel | |
interfaces = (graphene.relay.Node, ) | |
class Article(SQLAlchemyObjectType): | |
class Meta: | |
model = ArticleModel | |
interfaces = (graphene.relay.Node, ) | |
class Query(graphene.ObjectType): | |
node = graphene.relay.Node.Field() | |
person = graphene.Field(Person, uuid = graphene.Int()) | |
def resolve_person(self, args, context, info): | |
query = Person.get_query(context) | |
uuid = args.get('uuid') | |
return query.get(uuid) | |
schema = graphene.Schema(query=Query, types=[Person]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Thank you for sharing your examples.
I've tryed to follow you guidelines but when I'm trying to query it give me error = "resolve_quote() got an unexpected keyword argument 'id'"
Here is schema:
Here is the query:
Here is the how a quote object should result:
Also, I'm using postgre with Serial type as Primary key; Why is id looking like a string instead of a int ?
Thank you