API reference¶
Request¶
-
class
django_graph_api.
Request
(document, schema, variables=None, operation_name=None)[source]¶ -
__init__
(document, schema, variables=None, operation_name=None)[source]¶ Creates a Request object that can be validated and executed.
Parameters: - document –
The query string to execute.
e.g.
"query episodeNames { episodes { name } }"
- schema – A Schema object to run the query against
- variables – A
dict
of variables to pass to the query (optional) - operation_name – If the document contains multiple named queries, the name of the query to execute (optional)
- document –
-
Types¶
Non-scalar field types¶
-
class
django_graph_api.
Object
(ast, data, fragments, variable_definitions=None, variables=None)[source]¶ Subclass this to define an object node in a schema.
e.g.
class Character(Object): name = CharField()
-
class
django_graph_api.
RelatedField
(object_type, **kwargs)[source]¶ Defines a many-to-1 or 1-to-1 related field.
e.g.
class Character(Object): name = CharField() mother = RelatedField('self')
Can be queried like
... character { mother { name } } ...
And would return
... "character": { "mother": { "name": "Joyce Summers" } } ...
-
class
django_graph_api.
ManyRelatedField
(object_type, **kwargs)[source]¶ Defines a 1-to-many or many-to-many related field.
e.g.
class Character(Object): name = CharField() friends = RelatedField('self')
Can be queried like
... character { friends { name } } ...
And would return
... "character": { "friends": [ {"name": "Luke Skywalker"}, {"name": "Han Solo"} ] } ...
Scalar field types¶
-
class
django_graph_api.
BooleanField
(description=None, arguments=None, null=True)[source]¶ Defines a boolean field.
Querying on this field will return a bool or None.
-
class
django_graph_api.
CharField
(description=None, arguments=None, null=True)[source]¶ Defines a string field.
Querying on this field will return a str or None.
-
class
django_graph_api.
IdField
(description=None, arguments=None, null=True)[source]¶ Defines an id field.
Querying on this field will return a str or None.