-
Notifications
You must be signed in to change notification settings - Fork 822
expose livehtml autobuild in Makefile + Add API autodoc #971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
7384614
79f8470
882d18e
1184f07
07b87c5
f8a6aa2
2b01a8e
0bd4d93
e141e43
67f6976
17e57e7
42bfb37
e761d25
37d32de
125ef51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ __pycache__/ | |
# Distribution / packaging | ||
.Python | ||
env/ | ||
venv/ | ||
.venv/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
API Reference | ||
============= | ||
|
||
Schema | ||
------ | ||
|
||
.. autoclass:: graphene.types.schema.Schema | ||
:members: | ||
|
||
.. Uncomment sections / types as API documentation is fleshed out | ||
.. in each class | ||
|
||
Object types | ||
------------ | ||
|
||
.. autoclass:: graphene.ObjectType | ||
|
||
.. autoclass:: graphene.InputObjectType | ||
|
||
.. autoclass:: graphene.Mutation | ||
:members: | ||
|
||
Fields (Mounted Types) | ||
---------------------- | ||
|
||
.. autoclass:: graphene.Field | ||
|
||
.. autoclass:: graphene.Argument | ||
|
||
.. autoclass:: graphene.InputField | ||
|
||
Fields (Unmounted Types) | ||
------------------------ | ||
|
||
.. autoclass:: graphene.types.unmountedtype.UnmountedType | ||
|
||
GraphQL Scalars | ||
--------------- | ||
|
||
.. autoclass:: graphene.Int() | ||
|
||
.. autoclass:: graphene.Float() | ||
|
||
.. autoclass:: graphene.String() | ||
|
||
.. autoclass:: graphene.Boolean() | ||
|
||
.. autoclass:: graphene.ID() | ||
|
||
Graphene Scalars | ||
---------------- | ||
|
||
.. autoclass:: graphene.Date() | ||
|
||
.. autoclass:: graphene.DateTime() | ||
|
||
.. autoclass:: graphene.Time() | ||
|
||
.. autoclass:: graphene.Decimal() | ||
|
||
.. autoclass:: graphene.UUID() | ||
|
||
.. autoclass:: graphene.JSONString() | ||
|
||
Enum | ||
---- | ||
|
||
.. autoclass:: graphene.Enum() | ||
|
||
Structures | ||
---------- | ||
|
||
.. autoclass:: graphene.List | ||
|
||
.. autoclass:: graphene.NonNull | ||
|
||
Type Extension | ||
-------------- | ||
|
||
.. autoclass:: graphene.Interface() | ||
|
||
.. autoclass:: graphene.Union() | ||
|
||
Execution Metadata | ||
------------------ | ||
|
||
.. autoclass:: graphene.ResolveInfo | ||
|
||
.. autoclass:: graphene.Context | ||
|
||
.. autoclass:: graphql.execution.base.ExecutionResult | ||
|
||
.. Relay | ||
.. ----- | ||
|
||
.. .. autoclass:: graphene.Node | ||
|
||
.. .. autoclass:: graphene.GlobalID | ||
|
||
.. .. autoclass:: graphene.ClientIDMutation | ||
|
||
.. .. autoclass:: graphene.Connection | ||
|
||
.. .. autoclass:: graphene.ConnectionField | ||
|
||
.. .. autoclass:: graphene.PageInfo |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Required library | ||
Sphinx==1.5.3 | ||
sphinx-autobuild | ||
# Docs template | ||
http://graphene-python.org/sphinx_graphene_theme.zip |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,35 @@ | |||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
class Argument(MountedType): | ||||||||||||||||
""" | ||||||||||||||||
Makes an Argument available on a Field in the GraphQL schema. | ||||||||||||||||
|
||||||||||||||||
Arguments will be parsed and provided to resolver methods for fields as keyword arguments. | ||||||||||||||||
|
||||||||||||||||
All ``arg`` and ``**extra_args`` for a ``graphene.Field`` are implicitly mounted as Argument | ||||||||||||||||
using the below parameters. | ||||||||||||||||
|
||||||||||||||||
.. code:: python | ||||||||||||||||
|
||||||||||||||||
age = graphene.String( | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might want to run black on code snippets in docstrings here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I omit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd vote yes on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes from me too |
||||||||||||||||
# Boolean implicitly mounted as Argument | ||||||||||||||||
dog_years=graphene.Boolean(description='convert to dog years'), | ||||||||||||||||
# Boolean explicitly mounted as Argument | ||||||||||||||||
decades=graphene.Argument(graphene.Boolean, default_value=False) | ||||||||||||||||
) | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
|
||||||||||||||||
args: | ||||||||||||||||
type (class for a graphene.UnmountedType): must be a class (not an instance) of an | ||||||||||||||||
unmounted graphene type (ex. scalar or object) which is used for the type of this | ||||||||||||||||
argument in the GraphQL schema. | ||||||||||||||||
required (bool): indicates this argument as not null in the graphql scehma. Same behavior | ||||||||||||||||
as graphene.NonNull. Default False. | ||||||||||||||||
name (str): the name of the GraphQL argument. Defaults to parameter name. | ||||||||||||||||
description (str): the description of the GraphQL argument in the schema. | ||||||||||||||||
default_value (Any): The value to be provided if the user does not set this argument in | ||||||||||||||||
the operation. | ||||||||||||||||
""" | ||||||||||||||||
|
||||||||||||||||
def __init__( | ||||||||||||||||
self, | ||||||||||||||||
type, | ||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
class Context(object): | ||
""" | ||
Context can be used to make a convenient container for attributes to provide | ||
for execution for resolvers of a GraphQL operation like a query. | ||
|
||
.. code:: python | ||
|
||
context = Context(loaders=build_dataloaders(), request=my_web_request) | ||
schema.execute('{ hello(name: "world") }', context=context) | ||
|
||
def resolve_hello(parent, info, name): | ||
info.context.request # value set in Context | ||
info.context.loaders # value set in Context | ||
# ... | ||
|
||
args: | ||
**params (Dict[str, Any]): values to make available on Context instance as attributes. | ||
|
||
""" | ||
|
||
def __init__(self, **params): | ||
for key, value in params.items(): | ||
setattr(self, key, value) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -67,6 +67,28 @@ def from_enum(cls, enum, description=None, deprecation_reason=None): # noqa: N8 | |||||
|
||||||
|
||||||
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)): | ||||||
""" | ||||||
Enum type defintion | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Defines a static set of values that can be provided as a Field, Argument or InputField. | ||||||
|
||||||
.. code:: python | ||||||
|
||||||
class NameFormat(graphene.Enum): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to keep graphene to show exactly which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may be worth a larger conversation. Naming collisions with python modules like enum.Enum, for example. Perhaps a naming protocol going forward? As @ProjectCheshire pointed out in https://graphenetools.slack.com/archives/CGR4VCHUL/p1559524808014100, core-next has these types available as, for example:
See https://graphql-core-next.readthedocs.io/en/latest/intro.html#getting-started There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll keep the import close in all examples to avoid confusion. Agree with @phalt that the clash for name |
||||||
FIRST_LAST = 'first_last' | ||||||
LAST_FIRST = 'last_first' | ||||||
|
||||||
Meta: | ||||||
enum (optional, Enum): Python enum to use as a base for GraphQL Enum. | ||||||
|
||||||
name (optional, str): the name of the GraphQL type (must be unique in schema). Defaults to class | ||||||
name. | ||||||
description (optional, str): the description of the GraphQL type in the schema. Defaults to class | ||||||
docstring. | ||||||
deprecation_reason (optional, str): Setting this value indicates that the enum is | ||||||
depreciated and may provide instruction or reason on how for clients to proceed. | ||||||
""" | ||||||
|
||||||
@classmethod | ||||||
def __init_subclass_with_meta__(cls, enum=None, _meta=None, **options): | ||||||
if not _meta: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please pin this to a specific version