Skip to content

Commit 61d425e

Browse files
committed
Added readme and a small fix
1 parent 3ac5186 commit 61d425e

File tree

2 files changed

+83
-2
lines changed

2 files changed

+83
-2
lines changed

examples/falcon_mongoengine/README.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
```

examples/falcon_mongoengine/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
from mongoengine import connect
33
from .api import GraphQLResource, HelloWorldResource
44

5-
connect('exampledb', host='127.0.0.1', port=27017)
5+
connect('bookmarks_db', host='127.0.0.1', port=27017)
66
app = application = falcon.API()
77

88
helloWorld = HelloWorldResource()
99
graphQL = GraphQLResource()
1010

11-
app.add_route('', helloWorld)
11+
app.add_route('/', helloWorld)
1212
app.add_route('/graphql', graphQL)

0 commit comments

Comments
 (0)