Improved README

This commit is contained in:
Syrus Akbary 2015-10-06 23:13:10 -07:00
parent 6537154d9f
commit d7f4804f56
2 changed files with 14 additions and 20 deletions

View File

@ -1,7 +1,8 @@
# Graphene: Pythonic GraphQL [![Build Status](https://travis-ci.org/graphql-python/graphene.svg?branch=master)](https://travis-ci.org/graphql-python/graphene) [![Coverage Status](https://coveralls.io/repos/graphql-python/graphene/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-python/graphene?branch=master) # Graphene [![Build Status](https://travis-ci.org/graphql-python/graphene.svg?branch=master)](https://travis-ci.org/graphql-python/graphene) [![Coverage Status](https://coveralls.io/repos/graphql-python/graphene/badge.svg?branch=master&service=github)](https://coveralls.io/github/graphql-python/graphene?branch=master)
This is a library to use GraphQL in a Pythonic and easy way. Graphene is a Python library for creating GraphQL schemas/types easly.
It maps the models/fields to internal GraphQLlib objects without effort. Including automatic [Django models](#djangorelay-schema) conversion. It maps the models/fields to internal GraphQL objects without effort.
Including automatic [Django models](#djangorelay-schema) conversion.
## Installation ## Installation
@ -37,9 +38,7 @@ class Query(graphene.ObjectType):
schema = graphene.Schema(query=Query) schema = graphene.Schema(query=Query)
``` ```
### Querying Then Querying `graphene.Schema` is as simple as:
Querying `graphene.Schema` is as simple as:
```python ```python
query = ''' query = '''
@ -58,22 +57,17 @@ Graphene also supports Relay, check the [Starwars Relay example](tests/starwars_
```python ```python
class Ship(relay.Node): class Ship(relay.Node):
'''A ship in the Star Wars saga''' name = graphene.StringField()
name = graphene.StringField(description='The name of the ship.')
@classmethod @classmethod
def get_node(cls, id): def get_node(cls, id):
return Ship(getShip(id)) return Ship(your_ship_instance)
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
ships = relay.ConnectionField(Ship, description='The ships used by the faction.') ships = relay.ConnectionField(Ship)
node = relay.NodeField() node = relay.NodeField()
@resolve_only_args
def resolve_ships(self):
return [Ship(s) for s in getShips()]
``` ```
### Django+Relay Schema ### Django+Relay Schema
@ -85,7 +79,7 @@ class Ship(DjangoNode):
class Meta: class Meta:
model = YourDjangoModelHere model = YourDjangoModelHere
# only_fields = ('id', 'name') # Only map this fields from the model # only_fields = ('id', 'name') # Only map this fields from the model
# excluxe_fields ('field_to_excluxe', ) # Exclude mapping this fields from the model # exclude_fields ('field_to_exclude', ) # Exclude mapping this fields from the model
class Query(graphene.ObjectType): class Query(graphene.ObjectType):
node = relay.NodeField() node = relay.NodeField()

View File

@ -1,9 +1,9 @@
Graphene: Pythonic GraphQL |Build Status| |Coverage Status| Graphene |Build Status| |Coverage Status|
=========================================================== =========================================
This is a library to use GraphQL in a Pythonic and easy way. It maps the Graphene is a Python library for creating GraphQL schemas/types easly.
models/fields to internal GraphQLlib objects without effort. Including It maps the models/fields to internal GraphQL objects without effort.
automatic `Django models`_ conversion. Including automatic `Django models`_ conversion.
Installation Installation
------------ ------------