@@ -11,28 +11,28 @@ a query language for APIs created by Facebook.
1111[ ![ Dependency Updates] ( https://pyup.io/repos/github/graphql-python/graphql-core-next/shield.svg )] ( https://pyup.io/repos/github/graphql-python/graphql-core-next/ )
1212[ ![ Python 3 Status] ( https://pyup.io/repos/github/graphql-python/graphql-core-next/python-3-shield.svg )] ( https://pyup.io/repos/github/graphql-python/graphql-core-next/ )
1313
14- The current version 1.0.1 of GraphQL-core-next is up-to-date with GraphQL.js
15- version 14.0.2. All parts of the API are covered by an extensive test suite of
16- currently 1615 unit tests.
14+ The current version 1.0.1 of GraphQL-core-next is up-to-date with GraphQL.js version
15+ 14.0.2. All parts of the API are covered by an extensive test suite of currently 1615
16+ unit tests.
1717
1818
1919## Documentation
2020
2121A more detailed documentation for GraphQL-core-next can be found at
2222[ graphql-core-next.readthedocs.io] ( https://graphql-core-next.readthedocs.io/ ) .
2323
24- There will be also [ blog articles] ( https://cito.github.io/tags/graphql/ )
25- with more usage examples.
24+ There will be also [ blog articles] ( https://cito.github.io/tags/graphql/ ) with more usage
25+ examples.
2626
2727
2828## Getting started
2929
3030An overview of GraphQL in general is available in the
3131[ README] ( https://github.com/facebook/graphql/blob/master/README.md ) for the
3232[ Specification for GraphQL] ( https://github.com/facebook/graphql ) . That overview
33- describes a simple set of GraphQL examples that exist as [ tests] ( tests )
34- in this repository. A good way to get started with this repository is to walk
35- through that README and the corresponding tests in parallel.
33+ describes a simple set of GraphQL examples that exist as [ tests] ( tests ) in this
34+ repository. A good way to get started with this repository is to walk through that
35+ README and the corresponding tests in parallel.
3636
3737
3838## Installation
@@ -41,16 +41,16 @@ GraphQL-core-next can be installed from PyPI using the built-in pip command:
4141
4242 python -m pip install graphql-core-next
4343
44- Alternatively, you can also use [ pipenv] ( https://docs.pipenv.org/ ) for
45- installation in a virtual environment:
44+ Alternatively, you can also use [ pipenv] ( https://docs.pipenv.org/ ) for installation in a
45+ virtual environment:
4646
4747 pipenv install graphql-core-next
4848
4949
5050## Usage
5151
52- GraphQL-core-next provides two important capabilities: building a type schema,
53- and serving queries against that type schema.
52+ GraphQL-core-next provides two important capabilities: building a type schema, and
53+ serving queries against that type schema.
5454
5555First, build a GraphQL type schema which maps to your code base:
5656
@@ -68,20 +68,19 @@ schema = GraphQLSchema(
6868 }))
6969```
7070
71- This defines a simple schema with one type and one field, that resolves
72- to a fixed value. The ` resolve ` function can return a value, a co-routine
73- object or a list of these. It takes two positional arguments; the first one
74- provides the root or the resolved parent field, the second one provides a
75- ` GraphQLResolveInfo ` object which contains information about the execution
76- state of the query, including a ` context ` attribute holding per-request state
77- such as authentication information or database session. Any GraphQL arguments
78- are passed to the ` resolve ` functions as individual keyword arguments.
79-
80- Note that the signature of the resolver functions is a bit different in
81- GraphQL.js, where the context is passed separately and arguments are passed
82- as a single object. Also note that GraphQL fields must be passed as a
83- ` GraphQLField ` object explicitly. Similarly, GraphQL arguments must be
84- passed as ` GraphQLArgument ` objects.
71+ This defines a simple schema with one type and one field, that resolves to a fixed
72+ value. The ` resolve ` function can return a value, a co-routine object or a list of
73+ these. It takes two positional arguments; the first one provides the root or the
74+ resolved parent field, the second one provides a ` GraphQLResolveInfo ` object which
75+ contains information about the execution state of the query, including a ` context `
76+ attribute holding per-request state such as authentication information or database
77+ session. Any GraphQL arguments are passed to the ` resolve ` functions as individual
78+ keyword arguments.
79+
80+ Note that the signature of the resolver functions is a bit different in GraphQL.js,
81+ where the context is passed separately and arguments are passed as a single object.
82+ Also note that GraphQL fields must be passed as a ` GraphQLField ` object explicitly.
83+ Similarly, GraphQL arguments must be passed as ` GraphQLArgument ` objects.
8584
8685A more complex example is included in the top level [ tests] ( tests ) directory.
8786
@@ -101,8 +100,8 @@ This runs a query fetching the one field defined, and then prints the result:
101100ExecutionResult(data = {' hello' : ' world' }, errors = None )
102101```
103102
104- The ` graphql_sync ` function will first ensure the query is syntactically
105- and semantically valid before executing it, reporting errors otherwise.
103+ The ` graphql_sync ` function will first ensure the query is syntactically and
104+ semantically valid before executing it, reporting errors otherwise.
106105
107106``` python
108107from graphql import graphql_sync
@@ -120,9 +119,9 @@ ExecutionResult(data=None, errors=[GraphQLError(
120119 locations = [SourceLocation(line = 1 , column = 3 )])])
121120```
122121
123- The ` graphql_sync ` function assumes that all resolvers return values
124- synchronously. By using coroutines as resolvers, you can also create
125- results in an asynchronous fashion with the ` graphql ` function.
122+ The ` graphql_sync ` function assumes that all resolvers return values synchronously. By
123+ using coroutines as resolvers, you can also create results in an asynchronous fashion
124+ with the ` graphql ` function.
126125
127126``` python
128127import asyncio
@@ -161,29 +160,29 @@ finally:
161160
162161## Goals and restrictions
163162
164- GraphQL-core-next tries to reproduce the code of the reference implementation
165- GraphQL.js in Python as closely as possible and to stay up-to-date with
166- the latest development of GraphQL.js.
163+ GraphQL-core-next tries to reproduce the code of the reference implementation GraphQL.js
164+ in Python as closely as possible and to stay up-to-date with the latest development of
165+ GraphQL.js.
167166
168167It has been created as an alternative and potential successor to
169- [ GraphQL-core] ( https://github.com/graphql-python/graphql-core ) ,
170- a prior work by Syrus Akbary, based on an older version of GraphQL.js and
171- also targeting older Python versions. GraphQL-core also serves as as the
172- foundation for [ Graphene] ( http://graphene-python.org/ ) , a more high-level
173- framework for building GraphQL APIs in Python. Some parts of GraphQL-core-next
174- have been inspired by GraphQL-core or directly taken over with only slight
175- modifications, but most of the code has been re-implemented from scratch,
176- replicating the latest code in GraphQL.js very closely and adding type hints
177- for Python. Though GraphQL-core has also been updated and modernized to some
178- extend, it might be replaced by GraphQL-core-next in the future.
168+ [ GraphQL-core] ( https://github.com/graphql-python/graphql-core ) , a prior work
169+ by Syrus Akbary, based on an older version of GraphQL.js and also targeting
170+ older Python versions. GraphQL-core also serves as as the foundation for
171+ [ Graphene] ( http://graphene-python.org/ ) , a more high-level framework for building
172+ GraphQL APIs in Python. Some parts of GraphQL-core-next have been inspired by
173+ GraphQL-core or directly taken over with only slight modifications, but most of the code
174+ has been re-implemented from scratch, replicating the latest code in GraphQL.js very
175+ closely and adding type hints for Python. Though GraphQL-core has also been updated and
176+ modernized to some extend, it might be replaced by GraphQL-core-next in the future.
179177
180178Design goals for the GraphQL-core-next library are:
181179
182- * to be a simple, cruft-free, state-of-the-art implementation of GraphQL using
183- current library and language versions
184- * to be very close to the GraphQL.js reference implementation, while still
185- using a Pythonic API and code style
180+ * to be a simple, cruft-free, state-of-the-art implementation of GraphQL using current
181+ library and language versions
182+ * to be very close to the GraphQL.js reference implementation, while still using a
183+ Pythonic API and code style
186184* making use of Python type hints, similar to how GraphQL.js makes use of Flow
185+ * using of [ black] ( https://github.com/ambv/black ) for automatic code formatting
187186* replicate the complete Mocha-based test suite of GraphQL.js using
188187 [ pytest] ( https://docs.pytest.org/ )
189188
@@ -192,8 +191,7 @@ Some restrictions (mostly in line with the design goals):
192191* requires Python 3.6 or 3.7
193192* does not support some already deprecated methods and options of GraphQL.js
194193* supports asynchronous operations only via async.io
195- * does not support additional executors and middleware like GraphQL-core
196- (we are considering adding middleware later though)
194+ (does not support the additional executors in GraphQL-core)
197195* the benchmarks have not yet been ported to Python
198196
199197
0 commit comments