File tree Expand file tree Collapse file tree 2 files changed +83
-2
lines changed
examples/falcon_mongoengine Expand file tree Collapse file tree 2 files changed +83
-2
lines changed Original file line number Diff line number Diff line change
1
+
2
+ Example Falcon+MongoEngine Project
3
+ ================================
4
+
5
+ This example project demos integration between Graphene, Falcon and MongoEngine.
6
+
7
+ Getting started
8
+ ---------------
9
+
10
+ First you'll need to get the source of the project. Do this by cloning the
11
+ whole Graphene repository:
12
+
13
+ ``` bash
14
+ # Get the example project code
15
+ git clone
[email protected] :abawchen/graphene-mongo.git
16
+ cd graphene-mongo/examples/falcon_mongoengine
17
+ ```
18
+
19
+ Create a virtual environment.
20
+
21
+ ``` bash
22
+ # Create a virtualenv in which we can install the dependencies
23
+ virtualenv env
24
+ source env/bin/activate
25
+ ```
26
+
27
+ Now we can install our dependencies:
28
+
29
+ ``` bash
30
+ pip install -r requirements.txt
31
+ ```
32
+
33
+ Setup a mongodb connection and create a database.
34
+ See the mongoengine connection details in the * app.py* file
35
+
36
+ Start the server:
37
+
38
+ On windows:
39
+ ```
40
+ waitress-serve --port=9000 falcon_mongoengine.app:app
41
+ ```
42
+
43
+ On Linux:
44
+ ```
45
+ gunicorn -b 0.0.0.0:9000 falcon_mongoengine.app:app
46
+ ```
47
+
48
+ Now head on over to
49
+ [ http://127.0.0.1:9000/graphql?query= ] ( http://127.0.0.1:9000/graphql?query= )
50
+ and run some queries!
51
+
52
+ Example:
53
+
54
+ ```
55
+ http://127.0.0.1:9000/graphql?query=query
56
+ {
57
+ categories(first: 1, name: "Travel")
58
+ {
59
+ edges { node { name color } }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ```
65
+ http://127.0.0.1:9000/graphql?query=query
66
+ {
67
+ bookmarks(first: 10)
68
+ {
69
+ pageInfo { startCursor endCursor hasNextPage hasPreviousPage }
70
+ edges {
71
+ node { name url category { name color } tags }
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ For tests run:
78
+
79
+ ``` python
80
+ pytest - v
81
+ ```
Original file line number Diff line number Diff line change 2
2
from mongoengine import connect
3
3
from .api import GraphQLResource , HelloWorldResource
4
4
5
- connect ('exampledb ' , host = '127.0.0.1' , port = 27017 )
5
+ connect ('bookmarks_db ' , host = '127.0.0.1' , port = 27017 )
6
6
app = application = falcon .API ()
7
7
8
8
helloWorld = HelloWorldResource ()
9
9
graphQL = GraphQLResource ()
10
10
11
- app .add_route ('' , helloWorld )
11
+ app .add_route ('/ ' , helloWorld )
12
12
app .add_route ('/graphql' , graphQL )
You can’t perform that action at this time.
0 commit comments