forked from epfahl/graphene_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.py
43 lines (24 loc) · 834 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
33
34
35
36
37
38
39
40
41
42
43
import graphene
from graphene_sqlalchemy import SQLAlchemyObjectType
import models as m
import database as db
class Account(SQLAlchemyObjectType):
class Meta:
model = m.Account
class Location(SQLAlchemyObjectType):
class Meta:
model = m.Location
class User(SQLAlchemyObjectType):
class Meta:
model = m.User
class Query(graphene.ObjectType):
accounts = graphene.List(Account)
locations = graphene.List(Location)
users = graphene.List(User)
def resolve_accounts(self, *args, **kwargs):
return db.Session.query(m.Account).all()
def resolve_locations(self, *args, **kwargs):
return db.Session.query(m.Location).all()
def resolve_users(self, *args, **kwargs):
return db.Session.query(m.User).all()
Schema = graphene.Schema(query=Query)