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 ..types import Boolean, Int, List, String, AbstractType
|
||||
from ..types import AbstractType, Boolean, Int, List, String
|
||||
from ..types.field import Field
|
||||
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
||||
from ..types.options import Options
|
||||
|
|
|
@ -2,9 +2,10 @@ import re
|
|||
from functools import partial
|
||||
|
||||
import six
|
||||
|
||||
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 ..utils.is_base_type import is_base_type
|
||||
from ..utils.props import props
|
||||
|
|
|
@ -57,6 +57,7 @@ class NodeMeta(InterfaceMeta):
|
|||
|
||||
|
||||
class NodeField(Field):
|
||||
|
||||
def __init__(self, node, type=False, deprecation_reason=None,
|
||||
name=None, **kwargs):
|
||||
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 ..node import Node
|
||||
|
||||
|
@ -41,6 +41,7 @@ def test_connection_inherit_abstracttype():
|
|||
extra = String()
|
||||
|
||||
class MyObjectConnection(BaseConnection, Connection):
|
||||
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
|
@ -51,6 +52,7 @@ def test_connection_inherit_abstracttype():
|
|||
|
||||
def test_edge():
|
||||
class MyObjectConnection(Connection):
|
||||
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
|
@ -74,6 +76,7 @@ def test_edge_with_bases():
|
|||
extra = String()
|
||||
|
||||
class MyObjectConnection(Connection):
|
||||
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from graphql_relay.utils import base64
|
||||
|
||||
from ...types import ObjectType, Schema, String
|
||||
from ..connection import ConnectionField
|
||||
from ..node import Node
|
||||
from graphql_relay.utils import base64
|
||||
from ...types import ObjectType, String, Schema
|
||||
|
||||
letter_chars = ['A', 'B', 'C', 'D', 'E']
|
||||
|
||||
|
||||
class Letter(ObjectType):
|
||||
|
||||
class Meta:
|
||||
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():
|
||||
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():
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
from collections import OrderedDict
|
||||
import pytest
|
||||
|
||||
from ...types import (Argument, Field, InputField, InputObjectType, ObjectType,
|
||||
Schema, AbstractType, NonNull)
|
||||
from ...types import (AbstractType, Argument, Field, InputField,
|
||||
InputObjectType, NonNull, ObjectType, Schema)
|
||||
from ...types.scalars import String
|
||||
from ..connection import Connection
|
||||
from ..mutation import ClientIDMutation
|
||||
from ..node import Node
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from collections import OrderedDict
|
||||
import pytest
|
||||
|
||||
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 ..node import Node
|
||||
|
||||
|
@ -72,10 +71,11 @@ def test_node_query():
|
|||
|
||||
def test_subclassed_node_query():
|
||||
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 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():
|
||||
|
|
|
@ -36,4 +36,5 @@ __all__ = [
|
|||
'NonNull',
|
||||
'Argument',
|
||||
'Dynamic',
|
||||
'Union',
|
||||
]
|
||||
|
|
|
@ -2,8 +2,7 @@ import six
|
|||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
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
|
||||
|
||||
|
||||
class AbstractTypeMeta(type):
|
||||
|
|
|
@ -2,10 +2,10 @@ import six
|
|||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .abstracttype import AbstractTypeMeta
|
||||
from .inputfield import InputField
|
||||
from .options import Options
|
||||
from .unmountedtype import UnmountedType
|
||||
from .utils import yank_fields_from_attrs, get_base_fields, merge
|
||||
from .inputfield import InputField
|
||||
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||
|
||||
|
||||
class InputObjectTypeMeta(AbstractTypeMeta):
|
||||
|
|
|
@ -2,9 +2,9 @@ import six
|
|||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .abstracttype import AbstractTypeMeta
|
||||
from .options import Options
|
||||
from .utils import yank_fields_from_attrs, get_base_fields, merge
|
||||
from .field import Field
|
||||
from .options import Options
|
||||
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||
|
||||
|
||||
class InterfaceMeta(AbstractTypeMeta):
|
||||
|
|
|
@ -4,10 +4,10 @@ import six
|
|||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .abstracttype import AbstractTypeMeta
|
||||
from .field import Field
|
||||
from .interface import Interface
|
||||
from .options import Options
|
||||
from .utils import yank_fields_from_attrs, get_base_fields, merge
|
||||
from .field import Field
|
||||
from .utils import get_base_fields, merge, yank_fields_from_attrs
|
||||
|
||||
|
||||
class ObjectTypeMeta(AbstractTypeMeta):
|
||||
|
|
|
@ -40,6 +40,7 @@ class NonNull(Structure):
|
|||
|
||||
Note: the enforcement of non-nullability occurs within the executor.
|
||||
'''
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NonNull, self).__init__(*args, **kwargs)
|
||||
assert not isinstance(self.of_type, NonNull), (
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import json
|
||||
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 ..inputobjecttype import InputObjectType
|
||||
from ..scalars import String, Int
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import Int, String
|
||||
from ..schema import Schema
|
||||
from ..structures import List
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
|
||||
from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue,
|
||||
GraphQLField, GraphQLObjectType, GraphQLString,
|
||||
GraphQLInterfaceType, GraphQLInputObjectField,
|
||||
GraphQLInputObjectType)
|
||||
GraphQLField, GraphQLInputObjectField,
|
||||
GraphQLInputObjectType, GraphQLInterfaceType,
|
||||
GraphQLObjectType, GraphQLString)
|
||||
|
||||
from ..dynamic import Dynamic
|
||||
from ..enum import Enum
|
||||
from ..field import Field
|
||||
from ..inputfield import InputField
|
||||
from ..objecttype import ObjectType
|
||||
from ..inputobjecttype import InputObjectType
|
||||
from ..interface import Interface
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import String
|
||||
from ..typemap import TypeMap
|
||||
|
||||
|
@ -112,7 +112,7 @@ def test_interface():
|
|||
foo_field = fields['foo']
|
||||
assert isinstance(foo_field, GraphQLField)
|
||||
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 == {
|
||||
'bar': GraphQLArgument(GraphQLString, description='Argument description', default_value='x', out_name='bar')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user