Skip to content

Commit 30da96d

Browse files
committed
Updated version and README
1 parent 00c2735 commit 30da96d

File tree

2 files changed

+34
-31
lines changed

2 files changed

+34
-31
lines changed

README.rst

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ Relay Library for GraphQL Python
22
================================
33

44
This is a library to allow the easy creation of Relay-compliant servers
5-
using the `GraphQL Python <https://github.com/graphql-python/graphql-core>`__
6-
reference implementation of a GraphQL server.
5+
using the `GraphQL
6+
Python <https://github.com/graphql-python/graphql-core>`__ reference
7+
implementation of a GraphQL server.
78

89
Note: The code is a **exact** port of the original `graphql-relay js
910
implementation <https://github.com/graphql/graphql-relay-js>`__ from
1011
Facebook
1112

12-
|Build Status| |Coverage Status|
13+
|PyPI version| |Build Status| |Coverage Status|
1314

1415
Getting Started
1516
---------------
@@ -36,7 +37,7 @@ this repository is to walk through that documentation and the
3637
corresponding tests in this library together.
3738

3839
Using Relay Library for GraphQL Python (graphql-core)
39-
---------------------------------------------------
40+
-----------------------------------------------------
4041

4142
Install Relay Library for GraphQL Python
4243

@@ -46,8 +47,9 @@ Install Relay Library for GraphQL Python
4647
pip install graphql-relay
4748
4849
When building a schema for
49-
`GraphQL <https://github.com/graphql-python/graphql-core>`__, the provided library
50-
functions can be used to simplify the creation of Relay patterns.
50+
`GraphQL <https://github.com/graphql-python/graphql-core>`__, the
51+
provided library functions can be used to simplify the creation of Relay
52+
patterns.
5153

5254
Connections
5355
~~~~~~~~~~~
@@ -61,9 +63,9 @@ returning those types.
6163
- ``connection_definitions`` returns a ``connection_type`` and its
6264
associated ``edgeType``, given a name and a node type.
6365
- ``connection_from_list`` is a helper method that takes an array and
64-
the arguments from ``connection_args``, does pagination and filtering,
65-
and returns an object in the shape expected by a ``connection_type``'s
66-
``resolver`` function.
66+
the arguments from ``connection_args``, does pagination and
67+
filtering, and returns an object in the shape expected by a
68+
``connection_type``'s ``resolver`` function.
6769
- ``connection_from_promised_list`` is similar to
6870
``connection_from_list``, but it takes a promise that resolves to an
6971
array, and returns a promise that resolves to the expected shape by
@@ -77,7 +79,7 @@ schema <tests/starwars/schema.py>`__:
7779

7880
.. code:: python
7981
80-
shipConnection = connection_definitions('Ship', shipType).connection_type
82+
ship_edge, ship_connection = connection_definitions('Ship', shipType)
8183
8284
factionType = GraphQLObjectType(
8385
name= 'Faction',
@@ -120,20 +122,20 @@ nodes and for implementing global IDs around local IDs.
120122
to an object, and to determine the type of a given object.
121123
- ``to_global_id`` takes a type name and an ID specific to that type
122124
name, and returns a "global ID" that is unique among all types.
123-
- ``from_global_id`` takes the "global ID" created by ``toGlobalID``, and
124-
retuns the type name and ID used to create it.
125-
- ``global_id_field`` creates the configuration for an ``id`` field on a
126-
node.
127-
- ``plural_identifying_root_field`` creates a field that accepts a list of
128-
non-ID identifiers (like a username) and maps then to their
125+
- ``from_global_id`` takes the "global ID" created by ``toGlobalID``,
126+
and retuns the type name and ID used to create it.
127+
- ``global_id_field`` creates the configuration for an ``id`` field on
128+
a node.
129+
- ``plural_identifying_root_field`` creates a field that accepts a list
130+
of non-ID identifiers (like a username) and maps then to their
129131
corresponding objects.
130132

131133
An example usage of these methods from the `test
132134
schema <tests/starwars/schema.py>`__:
133135

134136
.. code:: python
135137
136-
def get_node(global_id, *args):
138+
def get_node(global_id, context, info):
137139
resolvedGlobalId = from_global_id(global_id)
138140
_type, _id = resolvedGlobalId.type, resolvedGlobalId.id
139141
if _type == 'Faction':
@@ -143,14 +145,13 @@ schema <tests/starwars/schema.py>`__:
143145
else:
144146
return None
145147
146-
def get_node_type(obj):
148+
def get_node_type(obj, context, info):
147149
if isinstance(obj, Faction):
148150
return factionType
149151
else:
150152
return shipType
151153
152-
_node_definitions = node_definitions(get_node, get_node_type)
153-
node_field, node_interface = _node_definitions.node_field, _node_definitions.node_interface
154+
node_interface, node_field = node_definitions(get_node, get_node_type)
154155
155156
factionType = GraphQLObjectType(
156157
name= 'Faction',
@@ -182,11 +183,11 @@ Mutations
182183
A helper function is provided for building mutations with single inputs
183184
and client mutation IDs.
184185

185-
- ``mutation_with_client_mutation_id`` takes a name, input fields, output
186-
fields, and a mutation method to map from the input fields to the
187-
output fields, performing the mutation along the way. It then creates
188-
and returns a field configuration that can be used as a top-level
189-
field on the mutation type.
186+
- ``mutation_with_client_mutation_id`` takes a name, input fields,
187+
output fields, and a mutation method to map from the input fields to
188+
the output fields, performing the mutation along the way. It then
189+
creates and returns a field configuration that can be used as a
190+
top-level field on the mutation type.
190191

191192
An example usage of these methods from the `test
192193
schema <tests/starwars/schema.py>`__:
@@ -240,10 +241,10 @@ schema <tests/starwars/schema.py>`__:
240241
241242
This code creates a mutation named ``IntroduceShip``, which takes a
242243
faction ID and a ship name as input. It outputs the ``Faction`` and the
243-
``Ship`` in question. ``mutate_and_get_payload`` then gets an object with a
244-
property for each input field, performs the mutation by constructing the
245-
new ship, then returns an object that will be resolved by the output
246-
fields.
244+
``Ship`` in question. ``mutate_and_get_payload`` then gets an object
245+
with a property for each input field, performs the mutation by
246+
constructing the new ship, then returns an object that will be resolved
247+
by the output fields.
247248

248249
Our mutation type then creates the ``introduceShip`` field using the
249250
return value of ``mutation_with_client_mutation_id``.
@@ -263,6 +264,8 @@ After developing, the full test suite can be evaluated by running:
263264
264265
python setup.py test # Use --pytest-args="-v -s" for verbose mode
265266
267+
.. |PyPI version| image:: https://badge.fury.io/py/graphql-relay.svg
268+
:target: https://badge.fury.io/py/graphql-relay
266269
.. |Build Status| image:: https://travis-ci.org/graphql-python/graphql-relay-py.svg?branch=master
267270
:target: https://travis-ci.org/graphql-python/graphql-relay-py
268271
.. |Coverage Status| image:: https://coveralls.io/repos/graphql-python/graphql-relay-py/badge.svg?branch=master&service=github

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def run_tests(self):
2424

2525
setup(
2626
name='graphql-relay',
27-
version='0.4b1',
27+
version='0.4.1',
2828

2929
description='Relay implementation for Python',
3030
long_description=open('README.rst').read(),
@@ -54,7 +54,7 @@ def run_tests(self):
5454
packages=find_packages(exclude=['tests']),
5555

5656
install_requires=[
57-
'graphql-core==0.5b3',
57+
'graphql-core>=0.5.0',
5858
'pypromise>=0.4.0'
5959
],
6060
tests_require=['pytest>=2.7.2'],

0 commit comments

Comments
 (0)