-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathschema.py
32 lines (23 loc) · 831 Bytes
/
schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import graphene
from graphene import relay
from graphene_sqlalchemy import SQLAlchemyObjectType, SQLAlchemyConnectionField
from models import db_session, Partner as PartnerModel, User as UserModel
class Partner(SQLAlchemyObjectType):
class Meta:
model = PartnerModel
interfaces = (relay.Node, )
class PartnerConnection(relay.Connection):
class Meta:
node = Partner
class User(SQLAlchemyObjectType):
class Meta:
model = UserModel
interfaces = (relay.Node, )
class UserConnection(relay.Connection):
class Meta:
node = User
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_users = SQLAlchemyConnectionField(User._meta.connection)
all_partners = SQLAlchemyConnectionField(Partner._meta.connection)
schema = graphene.Schema(query=Query)