Skip to content

Commit

Permalink
Export all useful names at the top level
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jan 28, 2022
1 parent e41ac17 commit 80ab7ba
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 19 deletions.
60 changes: 44 additions & 16 deletions src/graphql_relay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@
connection_args,
connection_definitions,
forward_connection_args,
page_info_type,
Connection,
ConnectionArguments,
ConnectionConstructor,
ConnectionCursor,
ConnectionType,
Edge,
EdgeConstructor,
EdgeType,
GraphQLConnectionDefinitions,
PageInfo,
PageInfoConstructor,
PageInfoType,
)

# Helpers for creating connections from arrays
Expand All @@ -25,19 +32,26 @@
cursor_to_offset,
get_offset_with_default,
offset_to_cursor,
SizedSliceable,
)

# Helper for creating mutations with client mutation IDs
from .mutation.mutation import mutation_with_client_mutation_id
from .mutation.mutation import (
mutation_with_client_mutation_id,
resolve_maybe_thunk,
MutationFn,
MutationFnWithoutArgs,
NullResult,
)

# Helper for creating node definitions
from .node.node import node_definitions
from .node.node import node_definitions, GraphQLNodeDefinitions

# Helper for creating plural identifying root fields
from .node.plural import plural_identifying_root_field

# Utilities for creating global IDs in systems that don't have them
from .node.node import from_global_id, global_id_field, to_global_id
from .node.node import from_global_id, global_id_field, to_global_id, ResolvedGlobalId

# Deprecated functions from older graphql-relay-py versions
# noinspection PyProtectedMember,PyUnresolvedReferences,PyDeprecation
Expand All @@ -52,30 +66,44 @@
__version_info_js__ = version_info_js

__all__ = [
"version",
"version_info",
"version_js",
"version_info_js",
"backward_connection_args",
"Connection",
"ConnectionArguments",
"ConnectionConstructor",
"ConnectionCursor",
"Edge",
"PageInfo",
"backward_connection_args",
"ConnectionType",
"connection_args",
"connection_definitions",
"forward_connection_args",
"GraphQLConnectionDefinitions",
"connection_from_array",
"connection_from_array_slice",
"connection_definitions",
"cursor_for_object_in_connection",
"cursor_to_offset",
"Edge",
"EdgeConstructor",
"EdgeType",
"forward_connection_args",
"from_global_id",
"get_offset_with_default",
"offset_to_cursor",
"global_id_field",
"GraphQLConnectionDefinitions",
"GraphQLNodeDefinitions",
"MutationFn",
"MutationFnWithoutArgs",
"mutation_with_client_mutation_id",
"node_definitions",
"NullResult",
"offset_to_cursor",
"PageInfo",
"PageInfoConstructor",
"PageInfoType",
"page_info_type",
"plural_identifying_root_field",
"from_global_id",
"global_id_field",
"ResolvedGlobalId",
"resolve_maybe_thunk",
"SizedSliceable",
"to_global_id",
"version",
"version_info",
"version_js",
"version_info_js",
]
1 change: 1 addition & 0 deletions src/graphql_relay/connection/array_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"cursor_to_offset",
"get_offset_with_default",
"offset_to_cursor",
"SizedSliceable",
]


Expand Down
10 changes: 9 additions & 1 deletion src/graphql_relay/connection/arrayconnection.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import warnings

# noinspection PyDeprecation
from .array_connection import (
connection_from_array,
connection_from_array_slice,
cursor_for_object_in_connection,
cursor_to_offset,
get_offset_with_default,
offset_to_cursor,
SizedSliceable,
)

# Deprecated functions from older graphql-relay-py versions
# noinspection PyProtectedMember,PyUnresolvedReferences,PyDeprecation
from .array_connection import ( # noqa: F401
connection_from_list,
connection_from_list_slice,
)

warnings.warn(
"The 'arrayconnection' module is deprecated. "
Expand All @@ -17,12 +25,12 @@
stacklevel=2,
)


__all__ = [
"connection_from_array",
"connection_from_array_slice",
"cursor_for_object_in_connection",
"cursor_to_offset",
"get_offset_with_default",
"offset_to_cursor",
"SizedSliceable",
]
11 changes: 9 additions & 2 deletions src/graphql_relay/connection/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,23 @@
from typing_extensions import Protocol # type: ignore

__all__ = [
"connection_definitions",
"forward_connection_args",
"backward_connection_args",
"connection_args",
"connection_definitions",
"forward_connection_args",
"page_info_type",
"Connection",
"ConnectionArguments",
"ConnectionConstructor",
"ConnectionCursor",
"ConnectionType",
"Edge",
"EdgeConstructor",
"EdgeType",
"GraphQLConnectionDefinitions",
"PageInfo",
"PageInfoConstructor",
"PageInfoType",
]


Expand Down
8 changes: 8 additions & 0 deletions src/graphql_relay/mutation/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
)
from graphql.pyutils import AwaitableOrValue

__all__ = [
"mutation_with_client_mutation_id",
"resolve_maybe_thunk",
"MutationFn",
"MutationFnWithoutArgs",
"NullResult",
]

# Note: Contrary to the Javascript implementation of MutationFn,
# the context is passed as part of the GraphQLResolveInfo and any arguments
# are passed individually as keyword arguments.
Expand Down
9 changes: 9 additions & 0 deletions src/graphql_relay/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
GraphQLTypeResolver,
)

__all__ = [
"from_global_id",
"global_id_field",
"node_definitions",
"to_global_id",
"GraphQLNodeDefinitions",
"ResolvedGlobalId",
]


class GraphQLNodeDefinitions(NamedTuple):

Expand Down
2 changes: 2 additions & 0 deletions src/graphql_relay/node/plural.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
get_nullable_type,
)

__all__ = ["plural_identifying_root_field"]


def plural_identifying_root_field(
arg_name: str,
Expand Down

0 comments on commit 80ab7ba

Please sign in to comment.