8000 Simple example showing embedded query · graphql-python/gql-next@81686c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 81686c6

Browse files
committed
Simple example showing embedded query
1 parent 52229dd commit 81686c6

File tree

6 files changed

+46
-0
lines changed

6 files changed

+46
-0
lines changed

examples/simple/.gql.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"schema": "http://localhost:5000/graphql",
3+
"endpoint": "http://localhost:5000/graphql",
4+
"documents": "./tests/**/*.gql",
5+
"custom_header_exports": ""
6+
}

examples/simple/bootstrap.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import gql.codec.fast_register
2+
3+
import client
4+
client.main()

examples/simple/client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# coding: gql
2+
3+
MY_QUERY = gql"""
4+
query hello_query {
5+
hello(argument: "World")
6+
}
7+
"""
8+
9+
def main():
10+
result = MY_QUERY.execute()
11+
print(result)
12+
13+
if __name__ == "__main__":
14+
main()

examples/simple/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
flask
2+
flask-graphql
3+
graphene~=2.1.3
4+
5+
6+
pip install ./../../../dist/gql-0.1.0-py3-none-any.whl

examples/simple/server.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import graphene
2+
from flask_graphql import GraphQLView
3+
from flask import Flask
4+
5+
class Query(graphene.ObjectType):
6+
hello = graphene.String(argument=graphene.String(default_value="stranger"))
7+
8+
def resolve_hello(self, info, argument):
9+
return 'Hello ' + argument
10+
11+
schema = graphene.Schema(query=Query)
12+
13+
14+
app = Flask(__name__)
15+
app.add_url_rule('/graphql', view_func=GraphQLView.as_view('graphql', schema=schema, graphiql=True))

examples/simple/start-server.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FLASK_APP=server.py flask run

0 commit comments

Comments
 (0)
0