mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Improved sorting/PEP8 syntax
This commit is contained in:
parent
8fb4214809
commit
f955280d1a
|
@ -6,7 +6,7 @@ import six
|
||||||
|
|
||||||
from graphql_relay import connection_from_list
|
from graphql_relay import connection_from_list
|
||||||
|
|
||||||
from ..types import Boolean, Int, List, String, AbstractType
|
from ..types import AbstractType, Boolean, Int, List, String
|
||||||
from ..types.field import Field
|
from ..types.field import Field
|
||||||
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
||||||
from ..types.options import Options
|
from ..types.options import Options
|
||||||
|
|
|
@ -2,9 +2,10 @@ import re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from promise import Promise
|
from promise import Promise
|
||||||
|
|
||||||
from ..types import Argument, Field, InputObjectType, String, AbstractType
|
from ..types import AbstractType, Argument, Field, InputObjectType, String
|
||||||
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from ..utils.props import props
|
from ..utils.props import props
|
||||||
|
|
|
@ -57,6 +57,7 @@ class NodeMeta(InterfaceMeta):
|
||||||
|
|
||||||
|
|
||||||
class NodeField(Field):
|
class NodeField(Field):
|
||||||
|
|
||||||
def __init__(self, node, type=False, deprecation_reason=None,
|
def __init__(self, node, type=False, deprecation_reason=None,
|
||||||
name=None, **kwargs):
|
name=None, **kwargs):
|
||||||
assert issubclass(node, Node), 'NodeField can only operate in Nodes'
|
assert issubclass(node, Node), 'NodeField can only operate in Nodes'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
from ...types import Field, List, NonNull, ObjectType, String, AbstractType
|
from ...types import AbstractType, Field, List, NonNull, ObjectType, String
|
||||||
from ..connection import Connection, PageInfo
|
from ..connection import Connection, PageInfo
|
||||||
from ..node import Node
|
from ..node import Node
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ def test_connection_inherit_abstracttype():
|
||||||
extra = String()
|
extra = String()
|
||||||
|
|
||||||
class MyObjectConnection(BaseConnection, Connection):
|
class MyObjectConnection(BaseConnection, Connection):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
node = MyObject
|
node = MyObject
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ def test_connection_inherit_abstracttype():
|
||||||
|
|
||||||
def test_edge():
|
def test_edge():
|
||||||
class MyObjectConnection(Connection):
|
class MyObjectConnection(Connection):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
node = MyObject
|
node = MyObject
|
||||||
|
|
||||||
|
@ -74,6 +76,7 @@ def test_edge_with_bases():
|
||||||
extra = String()
|
extra = String()
|
||||||
|
|
||||||
class MyObjectConnection(Connection):
|
class MyObjectConnection(Connection):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
node = MyObject
|
node = MyObject
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
from graphql_relay.utils import base64
|
||||||
|
|
||||||
|
from ...types import ObjectType, Schema, String
|
||||||
from ..connection import ConnectionField
|
from ..connection import ConnectionField
|
||||||
from ..node import Node
|
from ..node import Node
|
||||||
from graphql_relay.utils import base64
|
|
||||||
from ...types import ObjectType, String, Schema
|
|
||||||
|
|
||||||
letter_chars = ['A', 'B', 'C', 'D', 'E']
|
letter_chars = ['A', 'B', 'C', 'D', 'E']
|
||||||
|
|
||||||
|
|
||||||
class Letter(ObjectType):
|
class Letter(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (Node, )
|
interfaces = (Node, )
|
||||||
|
|
||||||
|
@ -163,7 +165,13 @@ def test_returns_all_elements_if_cursors_are_invalid():
|
||||||
|
|
||||||
|
|
||||||
def test_returns_all_elements_if_cursors_are_on_the_outside():
|
def test_returns_all_elements_if_cursors_are_on_the_outside():
|
||||||
check('before: "{}" after: "{}"'.format(base64('arrayconnection:%s' % 6), base64('arrayconnection:%s' % -1)), 'ABCDE')
|
check(
|
||||||
|
'before: "{}" after: "{}"'.format(
|
||||||
|
base64(
|
||||||
|
'arrayconnection:%s' % 6),
|
||||||
|
base64(
|
||||||
|
'arrayconnection:%s' % -1)),
|
||||||
|
'ABCDE')
|
||||||
|
|
||||||
|
|
||||||
def test_returns_no_elements_if_cursors_cross():
|
def test_returns_no_elements_if_cursors_cross():
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
from collections import OrderedDict
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ...types import (Argument, Field, InputField, InputObjectType, ObjectType,
|
from ...types import (AbstractType, Argument, Field, InputField,
|
||||||
Schema, AbstractType, NonNull)
|
InputObjectType, NonNull, ObjectType, Schema)
|
||||||
from ...types.scalars import String
|
from ...types.scalars import String
|
||||||
from ..connection import Connection
|
|
||||||
from ..mutation import ClientIDMutation
|
from ..mutation import ClientIDMutation
|
||||||
from ..node import Node
|
from ..node import Node
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
import pytest
|
|
||||||
|
|
||||||
from graphql_relay import to_global_id
|
from graphql_relay import to_global_id
|
||||||
|
|
||||||
from ...types import ObjectType, Schema, String, AbstractType
|
from ...types import AbstractType, ObjectType, Schema, String
|
||||||
from ..connection import Connection
|
from ..connection import Connection
|
||||||
from ..node import Node
|
from ..node import Node
|
||||||
|
|
||||||
|
@ -72,10 +71,11 @@ def test_node_query():
|
||||||
|
|
||||||
def test_subclassed_node_query():
|
def test_subclassed_node_query():
|
||||||
executed = schema.execute(
|
executed = schema.execute(
|
||||||
'{ node(id:"%s") { ... on MyOtherNode { shared, extraField, somethingElse } } }' % to_global_id("MyOtherNode", 1)
|
'{ node(id:"%s") { ... on MyOtherNode { shared, extraField, somethingElse } } }' %
|
||||||
)
|
to_global_id("MyOtherNode", 1))
|
||||||
assert not executed.errors
|
assert not executed.errors
|
||||||
assert executed.data == OrderedDict({'node': OrderedDict([('shared', '1'), ('extraField', 'extra field info.'), ('somethingElse', '----')])})
|
assert executed.data == OrderedDict({'node': OrderedDict(
|
||||||
|
[('shared', '1'), ('extraField', 'extra field info.'), ('somethingElse', '----')])})
|
||||||
|
|
||||||
|
|
||||||
def test_node_query_incorrect_id():
|
def test_node_query_incorrect_id():
|
||||||
|
|
|
@ -36,4 +36,5 @@ __all__ = [
|
||||||
'NonNull',
|
'NonNull',
|
||||||
'Argument',
|
'Argument',
|
||||||
'Dynamic',
|
'Dynamic',
|
||||||
|
'Union',
|
||||||
]
|
]
|
||||||
|
|
|
@ -2,8 +2,7 @@ import six
|
||||||
|
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from .options import Options
|
from .options import Options
|
||||||
from .utils import (yank_fields_from_attrs, get_base_fields,
|
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||||
merge)
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractTypeMeta(type):
|
class AbstractTypeMeta(type):
|
||||||
|
|
|
@ -2,10 +2,10 @@ import six
|
||||||
|
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from .abstracttype import AbstractTypeMeta
|
from .abstracttype import AbstractTypeMeta
|
||||||
|
from .inputfield import InputField
|
||||||
from .options import Options
|
from .options import Options
|
||||||
from .unmountedtype import UnmountedType
|
from .unmountedtype import UnmountedType
|
||||||
from .utils import yank_fields_from_attrs, get_base_fields, merge
|
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||||
from .inputfield import InputField
|
|
||||||
|
|
||||||
|
|
||||||
class InputObjectTypeMeta(AbstractTypeMeta):
|
class InputObjectTypeMeta(AbstractTypeMeta):
|
||||||
|
|
|
@ -2,9 +2,9 @@ import six
|
||||||
|
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from .abstracttype import AbstractTypeMeta
|
from .abstracttype import AbstractTypeMeta
|
||||||
from .options import Options
|
|
||||||
from .utils import yank_fields_from_attrs, get_base_fields, merge
|
|
||||||
from .field import Field
|
from .field import Field
|
||||||
|
from .options import Options
|
||||||
|
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||||
|
|
||||||
|
|
||||||
class InterfaceMeta(AbstractTypeMeta):
|
class InterfaceMeta(AbstractTypeMeta):
|
||||||
|
|
|
@ -4,10 +4,10 @@ import six
|
||||||
|
|
||||||
from ..utils.is_base_type import is_base_type
|
from ..utils.is_base_type import is_base_type
|
||||||
from .abstracttype import AbstractTypeMeta
|
from .abstracttype import AbstractTypeMeta
|
||||||
|
from .field import Field
|
||||||
from .interface import Interface
|
from .interface import Interface
|
||||||
from .options import Options
|
from .options import Options
|
||||||
from .utils import yank_fields_from_attrs, get_base_fields, merge
|
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||||
from .field import Field
|
|
||||||
|
|
||||||
|
|
||||||
class ObjectTypeMeta(AbstractTypeMeta):
|
class ObjectTypeMeta(AbstractTypeMeta):
|
||||||
|
|
|
@ -40,6 +40,7 @@ class NonNull(Structure):
|
||||||
|
|
||||||
Note: the enforcement of non-nullability occurs within the executor.
|
Note: the enforcement of non-nullability occurs within the executor.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(NonNull, self).__init__(*args, **kwargs)
|
super(NonNull, self).__init__(*args, **kwargs)
|
||||||
assert not isinstance(self.of_type, NonNull), (
|
assert not isinstance(self.of_type, NonNull), (
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import json
|
import json
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from graphql import execute, Source, parse
|
from graphql import Source, execute, parse
|
||||||
|
|
||||||
from ..objecttype import ObjectType
|
|
||||||
from ..inputfield import InputField
|
from ..inputfield import InputField
|
||||||
from ..inputobjecttype import InputObjectType
|
from ..inputobjecttype import InputObjectType
|
||||||
from ..scalars import String, Int
|
from ..objecttype import ObjectType
|
||||||
|
from ..scalars import Int, String
|
||||||
from ..schema import Schema
|
from ..schema import Schema
|
||||||
from ..structures import List
|
from ..structures import List
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
|
|
||||||
from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue,
|
from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue,
|
||||||
GraphQLField, GraphQLObjectType, GraphQLString,
|
GraphQLField, GraphQLInputObjectField,
|
||||||
GraphQLInterfaceType, GraphQLInputObjectField,
|
GraphQLInputObjectType, GraphQLInterfaceType,
|
||||||
GraphQLInputObjectType)
|
GraphQLObjectType, GraphQLString)
|
||||||
|
|
||||||
from ..dynamic import Dynamic
|
from ..dynamic import Dynamic
|
||||||
from ..enum import Enum
|
from ..enum import Enum
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ..inputfield import InputField
|
from ..inputfield import InputField
|
||||||
from ..objecttype import ObjectType
|
|
||||||
from ..inputobjecttype import InputObjectType
|
from ..inputobjecttype import InputObjectType
|
||||||
from ..interface import Interface
|
from ..interface import Interface
|
||||||
|
from ..objecttype import ObjectType
|
||||||
from ..scalars import String
|
from ..scalars import String
|
||||||
from ..typemap import TypeMap
|
from ..typemap import TypeMap
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ def test_interface():
|
||||||
foo_field = fields['foo']
|
foo_field = fields['foo']
|
||||||
assert isinstance(foo_field, GraphQLField)
|
assert isinstance(foo_field, GraphQLField)
|
||||||
assert foo_field.description == 'Field description'
|
assert foo_field.description == 'Field description'
|
||||||
assert not foo_field.resolver # Resolver not attached in interfaces
|
assert not foo_field.resolver # Resolver not attached in interfaces
|
||||||
assert foo_field.args == {
|
assert foo_field.args == {
|
||||||
'bar': GraphQLArgument(GraphQLString, description='Argument description', default_value='x', out_name='bar')
|
'bar': GraphQLArgument(GraphQLString, description='Argument description', default_value='x', out_name='bar')
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user