Skip to content

Commit 04c1632

Browse files
Update schema.py
1 parent 73f1e3f commit 04c1632

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

schema.py

+19
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
1+
user_type = GraphQLObjectType(
2+
name='User',
3+
fields={
4+
'id': GraphQLField(GraphQLString),
5+
'name': GraphQLField(GraphQLString)
6+
}
7+
)
18

9+
query_type = GraphQLObjectType(
10+
name='Query',
11+
fields={
12+
'users': GraphQLField(
13+
GraphQLList(user_type),
14+
resolver=lambda root, info: conn.cursor().execute('SELECT * FROM users').fetchall()
15+
)
16+
}
17+
)
18+
19+
schema = GraphQLSchema(query=query_type)
20+
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))

0 commit comments

Comments
 (0)