You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+48-35Lines changed: 48 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,45 @@
1
-
# GraphQL-core
1
+
# GraphQL-core 2
2
2
3
-
GraphQL for Python.
3
+
This is the repository of GraphQL for Python 2 (legacy version).
4
4
5
-
_This library is a port of [graphql-js](https://github.com/graphql/graphql-js) to Python and currently is up-to-date with release [0.6.0](https://github.com/graphql/graphql-js/releases/tag/v0.6.0)._
5
+
**The repository for the current version GraphQL is available at
Then, serve the result of a query against that type schema.
68
75
@@ -77,9 +84,8 @@ result = graphql(schema, query)
77
84
print result.data
78
85
```
79
86
80
-
This runs a query fetching the one field defined. The `graphql` function will
81
-
first ensure the query is syntactically and semantically valid before executing
82
-
it, reporting errors otherwise.
87
+
This runs a query fetching the one field defined. The `graphql` function will first ensure
88
+
the query is syntactically and semantically valid before executing it, reporting errors otherwise.
83
89
84
90
```python
85
91
query ='{ boyhowdy }'
@@ -94,8 +100,7 @@ print result.errors
94
100
95
101
### Executors
96
102
97
-
The graphql query is executed, by default, synchronously (using `SyncExecutor`).
98
-
However the following executors are available if we want to resolve our fields in parallel:
103
+
The graphql query is executed, by default, synchronously (using `SyncExecutor`). However the following executors are available if we want to resolve our fields in parallel:
99
104
100
105
-`graphql.execution.executors.asyncio.AsyncioExecutor`: This executor executes the resolvers in the Python asyncio event loop.
101
106
-`graphql.execution.executors.gevent.GeventExecutor`: This executor executes the resolvers in the Gevent event loop.
@@ -108,9 +113,15 @@ However the following executors are available if we want to resolve our fields i
108
113
You can specify the executor to use via the executor keyword argument in the `grapqhl.execution.execute` function.
109
114
110
115
```python
111
-
from graphql.execution.execute import execute
116
+
from graphql import parse
117
+
from graphql.execution import execute
118
+
from graphql.execution.executors.sync import SyncExecutor
119
+
120
+
ast = parse('{ hello }')
112
121
113
-
execute(schema, ast, executor=SyncExecutor())
122
+
result = execute(schema, ast, executor=SyncExecutor())
123
+
124
+
print result.data
114
125
```
115
126
116
127
### Contributing
@@ -126,15 +137,17 @@ pip install -e ".[test]"
126
137
Well-written tests and maintaining good test coverage is important to this project. While developing, run new and existing tests with:
127
138
128
139
```sh
129
-
py.test PATH/TO/MY/DIR/test_test.py # Single file
130
-
py.test PATH/TO/MY/DIR/ # All tests in directory
140
+
pytest PATH/TO/MY/DIR/test_test.py # Single file
141
+
pytest PATH/TO/MY/DIR/ # All tests in directory
131
142
```
132
143
133
144
Add the `-s` flag if you have introduced breakpoints into the code for debugging.
134
145
Add the `-v` ("verbose") flag to get more detailed test output. For even more detailed output, use `-vv`.
135
146
Check out the [pytest documentation](https://docs.pytest.org/en/latest/) for more options and test running controls.
136
147
137
-
GraphQL-core supports several versions of Python. To make sure that changes do not break compatibility with any of those versions, we use `tox` to create virtualenvs for each python version and run tests with that version. To run against all python versions defined in the `tox.ini` config file, just run:
148
+
GraphQL-core 2 supports several versions of Python. To make sure that changes do not break compatibility
149
+
with any of those versions, we use `tox` to create virtualenvs for each Python version and run tests with that version.
150
+
To run against all python versions defined in the `tox.ini` config file, just run:
138
151
139
152
```sh
140
153
tox
@@ -156,4 +169,4 @@ Tox can only use whatever versions of python are installed on your system. When
0 commit comments