Skip to content

Commit c54a79d

Browse files
committed
Revert to where we started the 'next' branch
1 parent 54fa427 commit c54a79d

28 files changed

+633
-381
lines changed

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.gitignore

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
# Created by https://www.gitignore.io
2+
3+
### Python ###
4+
# Byte-compiled / optimized / DLL files
15
__pycache__/
26
*.py[cod]
37

8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
412
.Python
13+
env/
514
build/
615
develop-eggs/
716
dist/
@@ -13,50 +22,40 @@ lib64/
1322
parts/
1423
sdist/
1524
var/
16-
wheels/
17-
pip-wheel-metadata/
18-
share/python-wheels/
1925
*.egg-info/
2026
.installed.cfg
2127
*.egg
22-
MANIFEST
2328

29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
2432
*.manifest
2533
*.spec
2634

35+
# Installer logs
2736
pip-log.txt
2837
pip-delete-this-directory.txt
2938

39+
# Unit test / coverage reports
3040
htmlcov/
3141
.tox/
32-
.nox/
3342
.coverage
3443
.coverage.*
3544
.cache
3645
nosetests.xml
3746
coverage.xml
38-
*.cover
39-
.pytest_cache/
47+
*,cover
4048

49+
# Translations
4150
*.mo
4251
*.pot
4352

53+
# Django stuff:
4454
*.log
4555

56+
# Sphinx documentation
4657
docs/_build/
4758

59+
# PyBuilder
4860
target/
4961

50-
.python-version
51-
52-
.env
53-
.venv
54-
env/
55-
venv/
56-
ENV/
57-
env.bak/
58-
venv.bak/
59-
60-
.mypy_cache/
61-
62-
.idea/

.travis.yml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,17 @@ language: python
22
dist: xenial
33

44
python:
5-
- "2.7"
6-
- "3.5"
7-
- "3.6"
8-
- "3.7"
9-
- "pypy3"
5+
- 2.7
6+
- 3.5
7+
- 3.6
8+
- 3.7
9+
- pypy3
1010
install:
11+
- pip install pytest pytest-cov flake8
1112
- pip install .
12-
- pip install "flake8>=3.7,<4"
1313
script:
14-
- python setup.py test -a "--cov=graphql_relay"
15-
- flake8 setup.py src tests
14+
- py.test --cov=graphql_relay
15+
# - flake8
1616
after_success:
1717
- pip install coveralls
1818
- coveralls
19-
20-
deploy:
21-
provider: pypi
22-
distributions: sdist bdist_wheel
23-
on:
24-
branch: master
25-
tags: true
26-
python: 3.7
27-
skip_existing: true
28-
user: mvanlonden
29-
password:
30-
secure: gu79sV5e3wkUI8eH20TbBRctOOGkuWe6EQUjJP17q1Jm15/sJsehOaaLPiG0psxtqBGABp+z+xXkjhRfNMowY2xJPLjGmpF23pOIWGjBWKLKXzJStegKM6kwJYyHzcykIhBEb74047FhqhcwOgZcsp6sZpfzuby+onevLzPDI0C4jTARw7WAqMln9JIBZJyoQKp9fpr8AoXL2JtHr6sjkeJ94lz1XViL9rtTo7qFYfqYS3XdKO0wJhLfMUXSihIzSWQykBVv+75tMKQr0CtGALXcJSRGT6Sb31GiFyG93rtcOcBvbjFt1MK8aNKyIMhwgSqjcgKvxWAvXn4MsCaabHPVEv0YuT9t9cQzaAvi81LqHkpALgpDfXFfsMzHG18/8ME9TpM8u52r/ST5lhukglfnxWVy4hg8VLZ0iiTtpS3hx1Ba4Uecr++6fI5X+KL3EPabApQM+t4rcC0h4mEbjq3IkZ/ANAIJ2UjKTMcUkbQbKqJ1MY4xQyw+vVugffBmhEWSb4GnQPEadMGD6qfUI+t7epDP0ipp67rOiUooFYGabQp40pf7MxFPG23fvJ3JWbo3fzcIRmQiSalrIL1gFXH2DQnv4xhZvwnci+dIK29mamH0CfmjAJ8BdfzRsjV156BZbfkzXRfWDMes9G2E8S27xJJ2N4ySNIMkaXsu1u4=
31-

MANIFEST.in

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
include MANIFEST.in
2-
1+
global-exclude tests/*
2+
recursive-exclude tests *
3+
recursive-exclude tests_py35 *
34
include LICENSE
4-
include README.md
5-
6-
include .flake8
7-
8-
include tox.ini
9-
10-
graft src/graphql_relay
11-
graft tests
12-
13-
global-exclude *.py[co] __pycache__

README.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ that documentation and the corresponding tests in this library together.
3636
Install Relay Library for GraphQL Python
3737

3838
```sh
39-
pip install "graphql-core>=2,<3" # use version 2.x of graphql-core
39+
pip install graphql-core --pre # Last version of graphql-core
4040
pip install graphql-relay
4141
```
4242

@@ -54,13 +54,13 @@ returning those types.
5454
they return a connection type.
5555
- `connection_definitions` returns a `connection_type` and its associated
5656
`edgeType`, given a name and a node type.
57-
- `connection_from_list` is a helper method that takes a list and the
57+
- `connection_from_list` is a helper method that takes an array and the
5858
arguments from `connection_args`, does pagination and filtering, and returns
5959
an object in the shape expected by a `connection_type`'s `resolver` function.
6060
- `connection_from_promised_list` is similar to `connection_from_list`, but
6161
it takes a promise that resolves to an array, and returns a promise that
6262
resolves to the expected shape by `connection_type`.
63-
- `cursor_for_object_in_connection` is a helper method that takes a list and a
63+
- `cursor_for_object_in_connection` is a helper method that takes an array and a
6464
member object, and returns a cursor for use in the mutation payload.
6565

6666
An example usage of these methods from the [test schema](tests/starwars/schema.py):
@@ -69,31 +69,32 @@ An example usage of these methods from the [test schema](tests/starwars/schema.p
6969
ship_edge, ship_connection = connection_definitions('Ship', shipType)
7070

7171
factionType = GraphQLObjectType(
72-
name='Faction',
73-
description='A faction in the Star Wars saga',
72+
name= 'Faction',
73+
description= 'A faction in the Star Wars saga',
7474
fields= lambda: {
7575
'id': global_id_field('Faction'),
7676
'name': GraphQLField(
7777
GraphQLString,
7878
description='The name of the faction.',
7979
),
8080
'ships': GraphQLField(
81-
ship_connection,
82-
description='The ships used by the faction.',
83-
args=connection_args,
84-
resolver=lambda faction, _info, **args: connection_from_list(
85-
[getShip(ship) for ship in faction.ships], args
81+
shipConnection,
82+
description= 'The ships used by the faction.',
83+
args= connection_args,
84+
resolver= lambda faction, args, *_: connection_from_list(
85+
map(getShip, faction.ships),
86+
args
8687
),
8788
)
8889
},
89-
interfaces=[node_interface]
90+
interfaces= [node_interface]
9091
)
9192
```
9293

9394
This shows adding a `ships` field to the `Faction` object that is a connection.
9495
It uses `connection_definitions({name: 'Ship', nodeType: shipType})` to create
9596
the connection type, adds `connection_args` as arguments on this function, and
96-
then implements the resolver function by passing the list of ships and the
97+
then implements the resolver function by passing the array of ships and the
9798
arguments to `connection_from_list`.
9899

99100
### Object Identification
@@ -107,7 +108,7 @@ this, it takes a function to resolve an ID to an object, and to determine
107108
the type of a given object.
108109
- `to_global_id` takes a type name and an ID specific to that type name,
109110
and returns a "global ID" that is unique among all types.
110-
- `from_global_id` takes the "global ID" created by `to_global_id`, and returns
111+
- `from_global_id` takes the "global ID" created by `toGlobalID`, and retuns
111112
the type name and ID used to create it.
112113
- `global_id_field` creates the configuration for an `id` field on a node.
113114
- `plural_identifying_root_field` creates a field that accepts a list of
@@ -117,16 +118,17 @@ objects.
117118
An example usage of these methods from the [test schema](tests/starwars/schema.py):
118119

119120
```python
120-
def get_node(global_id, _info):
121-
type_, id_ = from_global_id(global_id)
122-
if type_ == 'Faction':
123-
return getFaction(id_)
124-
elif type_ == 'Ship':
125-
return getShip(id_)
121+
def get_node(global_id, context, info):
122+
resolvedGlobalId = from_global_id(global_id)
123+
_type, _id = resolvedGlobalId.type, resolvedGlobalId.id
124+
if _type == 'Faction':
125+
return getFaction(_id)
126+
elif _type == 'Ship':
127+
return getShip(_id)
126128
else:
127129
return None
128130

129-
def get_node_type(obj, _info):
131+
def get_node_type(obj, context, info):
130132
if isinstance(obj, Faction):
131133
return factionType
132134
else:
@@ -175,9 +177,11 @@ class IntroduceShipMutation(object):
175177
def __init__(self, shipId, factionId, clientMutationId=None):
176178
self.shipId = shipId
177179
self.factionId = factionId
178-
self.clientMutationId = clientMutationId
180+
self.clientMutationId = None
179181

180-
def mutate_and_get_payload(_info, shipName, factionId, **_input):
182+
def mutate_and_get_payload(data, *_):
183+
shipName = data.get('shipName')
184+
factionId = data.get('factionId')
181185
newShip = createShip(shipName, factionId)
182186
return IntroduceShipMutation(
183187
shipId=newShip.id,
@@ -197,19 +201,19 @@ shipMutation = mutation_with_client_mutation_id(
197201
output_fields= {
198202
'ship': GraphQLField(
199203
shipType,
200-
resolver=lambda payload, _info: getShip(payload.shipId)
204+
resolver= lambda payload, *_: getShip(payload.shipId)
201205
),
202206
'faction': GraphQLField(
203207
factionType,
204-
resolver=lambda payload, _info: getFaction(payload.factionId)
208+
resolver= lambda payload, *_: getFaction(payload.factionId)
205209
)
206210
},
207211
mutate_and_get_payload=mutate_and_get_payload
208212
)
209213

210214
mutationType = GraphQLObjectType(
211215
'Mutation',
212-
fields=lambda: {
216+
fields= lambda: {
213217
'introduceShip': shipMutation
214218
}
215219
)

0 commit comments

Comments
 (0)