Skip to content

Commit 3de6454

Browse files
committed
Use 88 char line length for docstrings and docs
1 parent 2255e02 commit 3de6454

35 files changed

+372
-393
lines changed

README.md

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2121
A 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

3030
An 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

5555
First, 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

8685
A 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:
101100
ExecutionResult(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
108107
from 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
128127
import 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

168167
It 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

180178
Design 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

docs/modules/error.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Error
1010
.. autofunction:: print_error
1111
.. autofunction:: format_error
1212

13-
The :mod:`graphql.error` module also contains the :const:`INVALID` singleton
14-
that is used to describe invalid or undefined values and corresponds to the
15-
``undefined`` value in GraphQL.js.
13+
The :mod:`graphql.error` module also contains the :const:`INVALID` singleton that is
14+
used to describe invalid or undefined values and corresponds to the ``undefined``
15+
value in GraphQL.js.

docs/modules/language.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,5 @@ Visitor
9999
.. autoclass:: ParallelVisitor
100100
.. autoclass:: TypeInfoVisitor
101101

102-
The module also exports the constants :const:`BREAK`, :const:`SKIP`,
103-
:const:`REMOVE` and :const:`IDLE` that are used as special return values
104-
in the :class:`Visitor` methods.
102+
The module also exports the constants :const:`BREAK`, :const:`SKIP`, :const:`REMOVE` and
103+
:const:`IDLE` that are used as special return values in the :class:`Visitor` methods.

docs/modules/utilities.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Create a GraphQL language AST from a Python value:
5959

6060
.. autofunction:: ast_from_value
6161

62-
A helper to use within recursive-descent visitors which need to be aware of
63-
the GraphQL type system:
62+
A helper to use within recursive-descent visitors which need to be aware of the GraphQL
63+
type system:
6464

6565
.. autoclass:: TypeInfo
6666

docs/modules/validation.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Validation
1010
Rules
1111
-----
1212

13-
This list includes all validation rules defined by the GraphQL spec.
14-
The order of the rules in this list has been adjusted to lead to the
15-
most clear output when encountering multiple validation errors:
13+
This list includes all validation rules defined by the GraphQL spec. The order of the
14+
rules in this list has been adjusted to lead to the most clear output when encountering
15+
multiple validation errors:
1616

1717
.. autodata:: specified_rules
1818

docs/usage/extension.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Extending a Schema
22
------------------
33

4-
With GraphQL-core-next you can also extend a given schema using type
5-
extensions. For example, we might want to add a ``lastName`` property to our
6-
``Human`` data type to retrieve only the last name of the person.
4+
With GraphQL-core-next you can also extend a given schema using type extensions. For
5+
example, we might want to add a ``lastName`` property to our ``Human`` data type to
6+
retrieve only the last name of the person.
77

8-
This can be achieved with the :func:`graphql.utilities.extend_schema`
9-
function as follows::
8+
This can be achieved with the :func:`graphql.utilities.extend_schema` function as
9+
follows::
1010

1111
from graphql import extend_schema, parse
1212

@@ -16,10 +16,9 @@ function as follows::
1616
}
1717
"""))
1818

19-
Note that this function expects the extensions as an AST, which we can
20-
get using the :func:`graphql.language.parse` function. Also note that
21-
the `extend_schema` function does not alter the original schema, but
22-
returns a new schema object.
19+
Note that this function expects the extensions as an AST, which we can get using the
20+
:func:`graphql.language.parse` function. Also note that the `extend_schema` function
21+
does not alter the original schema, but returns a new schema object.
2322

2423
We also need to attach a resolver function to the new field::
2524

@@ -45,3 +44,4 @@ This query will give the following result::
4544
ExecutionResult(
4645
data={'human': {'lastName': 'Skywalker', 'homePlanet': 'Tatooine'}},
4746
errors=None)
47+

docs/usage/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Usage
22
=====
33

4-
GraphQL-core-next provides two important capabilities: building a type schema,
5-
and serving queries against that type schema.
4+
GraphQL-core-next provides two important capabilities: building a type schema, and
5+
serving queries against that type schema.
66

77
.. toctree::
88
:maxdepth: 2

docs/usage/introspection.rst

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
Using an Introspection Query
22
----------------------------
33

4-
A third way of building a schema is using an introspection query on an
5-
existing server. This is what GraphiQL uses to get information about the
6-
schema on the remote server. You can create an introspection query using
7-
GraphQL-core-next with::
4+
A third way of building a schema is using an introspection query on an existing server.
5+
This is what GraphiQL uses to get information about the schema on the remote server. You
6+
can create an introspection query using GraphQL-core-next with::
87

98
from graphql import get_introspection_query
109

1110
query = get_introspection_query(descriptions=True)
1211

13-
This will also yield the descriptions of the introspected schema fields.
14-
You can also create a query that omits the descriptions with::
12+
This will also yield the descriptions of the introspected schema fields. You can also
13+
create a query that omits the descriptions with::
1514

1615
query = get_introspection_query(descriptions=False)
1716

18-
In practice you would run this query against a remote server, but we can
19-
also run it against the schema we have just built above::
17+
In practice you would run this query against a remote server, but we can also run it
18+
against the schema we have just built above::
2019

2120
introspection_query_result = graphql_sync(schema, query)
2221

23-
The ``data`` attribute of the introspection query result now gives us a
24-
dictionary, which constitutes a third way of describing a GraphQL schema::
22+
The ``data`` attribute of the introspection query result now gives us a dictionary,
23+
which constitutes a third way of describing a GraphQL schema::
2524

2625
{'__schema': {
2726
'queryType': {'name': 'Query'},
@@ -36,21 +35,20 @@ dictionary, which constitutes a third way of describing a GraphQL schema::
3635
... }
3736
}
3837

39-
This result contains all the information that is available in the SDL
40-
description of the schema, i.e. it does not contain the resolve functions
41-
and information on the server-side values of the enum types.
38+
This result contains all the information that is available in the SDL description of the
39+
schema, i.e. it does not contain the resolve functions and information on the
40+
server-side values of the enum types.
4241

43-
You can convert the introspection result into ``GraphQLSchema`` with
44-
GraphQL-core-next by using the :func:`graphql.utilities.build_client_schema`
45-
function::
42+
You can convert the introspection result into ``GraphQLSchema`` with GraphQL-core-next
43+
by using the :func:`graphql.utilities.build_client_schema` function::
4644

4745
from graphql import build_client_schema
4846

4947
client_schema = build_client_schema(introspection_query_result.data)
5048

5149

52-
It is also possible to convert the result to SDL with GraphQL-core-next by
53-
using the :func:`graphql.utilities.print_schema` function::
50+
It is also possible to convert the result to SDL with GraphQL-core-next by using the
51+
:func:`graphql.utilities.print_schema` function::
5452

5553
from graphql import print_schema
5654

@@ -59,5 +57,5 @@ using the :func:`graphql.utilities.print_schema` function::
5957

6058
This prints the SDL representation of the schema that we started with.
6159

62-
As you see, it is easy to convert between the three forms of representing
63-
a GraphQL schema in GraphQL-core-next.
60+
As you see, it is easy to convert between the three forms of representing a GraphQL
61+
schema in GraphQL-core-next.

0 commit comments

Comments
 (0)