mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-08 23:50:38 +03:00
Fixed PEP8 errors
This commit is contained in:
parent
9f1c5fa682
commit
6fa32a7287
|
@ -22,12 +22,14 @@ class Character(graphene.Interface):
|
||||||
|
|
||||||
|
|
||||||
class Human(graphene.ObjectType):
|
class Human(graphene.ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (Character, )
|
interfaces = (Character, )
|
||||||
home_planet = graphene.String()
|
home_planet = graphene.String()
|
||||||
|
|
||||||
|
|
||||||
class Droid(graphene.ObjectType):
|
class Droid(graphene.ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (Character, )
|
interfaces = (Character, )
|
||||||
primary_function = graphene.String()
|
primary_function = graphene.String()
|
||||||
|
|
|
@ -6,16 +6,15 @@ import six
|
||||||
|
|
||||||
from graphql_relay import connection_from_list
|
from graphql_relay import connection_from_list
|
||||||
|
|
||||||
from ..types import Boolean, String, List, Int
|
from ..types import 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
|
||||||
|
from ..types.utils import get_fields_in_type, yank_fields_from_attrs
|
||||||
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
|
||||||
from .node import Node, is_node
|
from .node import Node, is_node
|
||||||
|
|
||||||
from ..types.utils import get_fields_in_type, yank_fields_from_attrs
|
|
||||||
|
|
||||||
|
|
||||||
class PageInfo(ObjectType):
|
class PageInfo(ObjectType):
|
||||||
has_next_page = Boolean(
|
has_next_page = Boolean(
|
||||||
|
@ -66,7 +65,6 @@ class ConnectionMeta(ObjectTypeMeta):
|
||||||
if not options.name:
|
if not options.name:
|
||||||
options.name = '{}Connection'.format(base_name)
|
options.name = '{}Connection'.format(base_name)
|
||||||
|
|
||||||
|
|
||||||
edge_class = attrs.pop('Edge', None)
|
edge_class = attrs.pop('Edge', None)
|
||||||
edge_fields = OrderedDict([
|
edge_fields = OrderedDict([
|
||||||
('node', Field(options.node, description='The item at the end of the edge')),
|
('node', Field(options.node, description='The item at the end of the edge')),
|
||||||
|
@ -75,28 +73,29 @@ class ConnectionMeta(ObjectTypeMeta):
|
||||||
edge_attrs = props(edge_class) if edge_class else OrderedDict()
|
edge_attrs = props(edge_class) if edge_class else OrderedDict()
|
||||||
extended_edge_fields = get_fields_in_type(ObjectType, edge_attrs)
|
extended_edge_fields = get_fields_in_type(ObjectType, edge_attrs)
|
||||||
edge_fields.update(extended_edge_fields)
|
edge_fields.update(extended_edge_fields)
|
||||||
EdgeMeta = type('Meta', (object, ), {
|
edge_meta = type('Meta', (object, ), {
|
||||||
'fields': edge_fields,
|
'fields': edge_fields,
|
||||||
'name': '{}Edge'.format(base_name)
|
'name': '{}Edge'.format(base_name)
|
||||||
})
|
})
|
||||||
yank_fields_from_attrs(edge_attrs, extended_edge_fields)
|
yank_fields_from_attrs(edge_attrs, extended_edge_fields)
|
||||||
Edge = type('Edge', (ObjectType,), dict(edge_attrs, Meta=EdgeMeta))
|
edge = type('Edge', (ObjectType,), dict(edge_attrs, Meta=edge_meta))
|
||||||
|
|
||||||
options.local_fields = OrderedDict([
|
options.local_fields = OrderedDict([
|
||||||
('page_info', Field(PageInfo, name='pageInfo', required=True)),
|
('page_info', Field(PageInfo, name='pageInfo', required=True)),
|
||||||
('edges', Field(List(Edge)))
|
('edges', Field(List(edge)))
|
||||||
])
|
])
|
||||||
typed_fields = get_fields_in_type(ObjectType, attrs)
|
typed_fields = get_fields_in_type(ObjectType, attrs)
|
||||||
options.local_fields.update(typed_fields)
|
options.local_fields.update(typed_fields)
|
||||||
options.fields = options.local_fields
|
options.fields = options.local_fields
|
||||||
yank_fields_from_attrs(attrs, typed_fields)
|
yank_fields_from_attrs(attrs, typed_fields)
|
||||||
|
|
||||||
return type.__new__(cls, name, bases, dict(attrs, _meta=options, Edge=Edge))
|
return type.__new__(cls, name, bases, dict(attrs, _meta=options, Edge=edge))
|
||||||
|
|
||||||
|
|
||||||
class Connection(six.with_metaclass(ConnectionMeta, ObjectType)):
|
class Connection(six.with_metaclass(ConnectionMeta, ObjectType)):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IterableConnectionField(Field):
|
class IterableConnectionField(Field):
|
||||||
|
|
||||||
def __init__(self, type, *args, **kwargs):
|
def __init__(self, type, *args, **kwargs):
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
import re
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import re
|
|
||||||
|
|
||||||
from promise import Promise
|
from promise import Promise
|
||||||
|
|
||||||
|
from ..types import Argument, Field, InputObjectType, String
|
||||||
|
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
|
||||||
from ..types import Field, String, InputObjectType, Argument
|
|
||||||
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
|
||||||
|
|
||||||
|
|
||||||
class ClientIDMutationMeta(ObjectTypeMeta):
|
class ClientIDMutationMeta(ObjectTypeMeta):
|
||||||
|
@ -36,6 +35,7 @@ class ClientIDMutationMeta(ObjectTypeMeta):
|
||||||
|
|
||||||
|
|
||||||
class ClientIDMutation(six.with_metaclass(ClientIDMutationMeta, ObjectType)):
|
class ClientIDMutation(six.with_metaclass(ClientIDMutationMeta, ObjectType)):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def mutate(cls, root, args, context, info):
|
def mutate(cls, root, args, context, info):
|
||||||
input = args.get('input')
|
input = args.get('input')
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import six
|
|
||||||
from collections import OrderedDict
|
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
from graphql_relay import from_global_id, to_global_id
|
from graphql_relay import from_global_id, to_global_id
|
||||||
from ..types import ObjectType, Interface, ID, Field
|
|
||||||
|
from ..types import ID, Field, Interface, ObjectType
|
||||||
from ..types.interface import InterfaceMeta
|
from ..types.interface import InterfaceMeta
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +28,7 @@ def get_default_connection(cls):
|
||||||
|
|
||||||
|
|
||||||
class GlobalID(Field):
|
class GlobalID(Field):
|
||||||
|
|
||||||
def __init__(self, node, *args, **kwargs):
|
def __init__(self, node, *args, **kwargs):
|
||||||
super(GlobalID, self).__init__(ID, *args, **kwargs)
|
super(GlobalID, self).__init__(ID, *args, **kwargs)
|
||||||
self.node = node
|
self.node = node
|
||||||
|
@ -52,7 +54,7 @@ class Node(six.with_metaclass(NodeMeta, Interface)):
|
||||||
'''An object with an ID'''
|
'''An object with an ID'''
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Field(cls):
|
def Field(cls): # noqa: N802
|
||||||
def resolve_node(root, args, context, info):
|
def resolve_node(root, args, context, info):
|
||||||
return cls.get_node_from_global_id(args.get('id'), context, info)
|
return cls.get_node_from_global_id(args.get('id'), context, info)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
|
||||||
from ...types import ObjectType, Schema, List, Field, String, NonNull
|
from ...types import Field, List, NonNull, ObjectType, Schema, String
|
||||||
from ..connection import Connection, PageInfo
|
from ..connection import Connection, PageInfo
|
||||||
from ..node import Node
|
from ..node import Node
|
||||||
|
|
||||||
|
|
||||||
class MyObject(ObjectType):
|
class MyObject(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = [Node]
|
interfaces = [Node]
|
||||||
field = String()
|
field = String()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ...types import ObjectType, Schema, Field, InputField, InputObjectType, Argument
|
from ...types import (Argument, Field, InputField, InputObjectType, ObjectType,
|
||||||
|
Schema)
|
||||||
from ...types.scalars import String
|
from ...types.scalars import String
|
||||||
from ..mutation import ClientIDMutation
|
from ..mutation import ClientIDMutation
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ from ..node import Node
|
||||||
|
|
||||||
|
|
||||||
class MyNode(ObjectType):
|
class MyNode(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (Node, )
|
interfaces = (Node, )
|
||||||
name = String()
|
name = String()
|
||||||
|
@ -27,6 +28,7 @@ schema = Schema(query=RootQuery, types=[MyNode])
|
||||||
def test_node_no_get_node():
|
def test_node_no_get_node():
|
||||||
with pytest.raises(AssertionError) as excinfo:
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
class MyNode(ObjectType):
|
class MyNode(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (Node, )
|
interfaces = (Node, )
|
||||||
|
|
||||||
|
@ -36,6 +38,7 @@ def test_node_no_get_node():
|
||||||
def test_node_no_get_node_with_meta():
|
def test_node_no_get_node_with_meta():
|
||||||
with pytest.raises(AssertionError) as excinfo:
|
with pytest.raises(AssertionError) as excinfo:
|
||||||
class MyNode(ObjectType):
|
class MyNode(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (Node, )
|
interfaces = (Node, )
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
from graphql import graphql
|
from graphql import graphql
|
||||||
|
|
||||||
from ...types import ObjectType, Interface, Schema
|
from ...types import Interface, ObjectType, Schema
|
||||||
from ...types.scalars import Int, String
|
from ...types.scalars import Int, String
|
||||||
from ..node import Node
|
from ..node import Node
|
||||||
|
|
||||||
|
|
||||||
class CustomNode(Node):
|
class CustomNode(Node):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = 'Node'
|
name = 'Node'
|
||||||
|
|
||||||
|
@ -27,12 +28,14 @@ class BasePhoto(Interface):
|
||||||
|
|
||||||
|
|
||||||
class User(ObjectType):
|
class User(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = [CustomNode]
|
interfaces = [CustomNode]
|
||||||
name = String()
|
name = String()
|
||||||
|
|
||||||
|
|
||||||
class Photo(ObjectType):
|
class Photo(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = [CustomNode, BasePhoto]
|
interfaces = [CustomNode, BasePhoto]
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ from .enum import Enum
|
||||||
from .field import Field
|
from .field import Field
|
||||||
from .inputfield import InputField
|
from .inputfield import InputField
|
||||||
from .argument import Argument
|
from .argument import Argument
|
||||||
from .dynamic import Dynamic
|
|
||||||
from .inputobjecttype import InputObjectType
|
from .inputobjecttype import InputObjectType
|
||||||
|
from .dynamic import Dynamic
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'AbstractType',
|
'AbstractType',
|
||||||
|
@ -28,4 +28,5 @@ __all__ = [
|
||||||
'Boolean',
|
'Boolean',
|
||||||
'List',
|
'List',
|
||||||
'NonNull',
|
'NonNull',
|
||||||
'Argument']
|
'Argument'
|
||||||
|
'Dynamic']
|
||||||
|
|
|
@ -2,8 +2,8 @@ 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 (get_fields_in_type, merge_fields_in_attrs,
|
||||||
from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs
|
yank_fields_from_attrs)
|
||||||
|
|
||||||
|
|
||||||
class AbstractTypeMeta(type):
|
class AbstractTypeMeta(type):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from ..utils.orderedtype import OrderedType
|
from ..utils.orderedtype import OrderedType
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,15 @@ class EnumTypeMeta(type):
|
||||||
return cls.from_enum(PyEnum(*args, **kwargs), description=description)
|
return cls.from_enum(PyEnum(*args, **kwargs), description=description)
|
||||||
return super(EnumTypeMeta, cls).__call__(*args, **kwargs)
|
return super(EnumTypeMeta, cls).__call__(*args, **kwargs)
|
||||||
|
|
||||||
def from_enum(cls, enum, description=None):
|
def from_enum(cls, enum, description=None): # noqa: N805
|
||||||
meta_class = type('Meta', (object,), {'enum': enum, 'description': description})
|
meta_class = type('Meta', (object,), {'enum': enum, 'description': description})
|
||||||
return type(meta_class.enum.__name__, (Enum,), {'Meta': meta_class})
|
return type(meta_class.enum.__name__, (Enum,), {'Meta': meta_class})
|
||||||
|
|
||||||
def __str__(cls):
|
def __str__(cls): # noqa: N805
|
||||||
return cls._meta.name
|
return cls._meta.name
|
||||||
|
|
||||||
|
|
||||||
class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)):
|
class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)):
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return type(self)
|
return type(self)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
from collections import Mapping, OrderedDict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from collections import OrderedDict, Mapping
|
|
||||||
|
|
||||||
from ..utils.orderedtype import OrderedType
|
from ..utils.orderedtype import OrderedType
|
||||||
from .structures import NonNull
|
|
||||||
from .argument import to_arguments
|
from .argument import to_arguments
|
||||||
|
from .structures import NonNull
|
||||||
|
|
||||||
|
|
||||||
def source_resolver(source, root, args, context, info):
|
def source_resolver(source, root, args, context, info):
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import six
|
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 .abstracttype import AbstractTypeMeta
|
from .abstracttype import AbstractTypeMeta
|
||||||
from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs
|
from .options import Options
|
||||||
from .unmountedtype import UnmountedType
|
from .unmountedtype import UnmountedType
|
||||||
|
from .utils import (get_fields_in_type, merge_fields_in_attrs,
|
||||||
|
yank_fields_from_attrs)
|
||||||
|
|
||||||
|
|
||||||
class InputObjectTypeMeta(AbstractTypeMeta):
|
class InputObjectTypeMeta(AbstractTypeMeta):
|
||||||
|
@ -30,7 +30,7 @@ class InputObjectTypeMeta(AbstractTypeMeta):
|
||||||
|
|
||||||
return type.__new__(cls, name, bases, dict(attrs, _meta=options))
|
return type.__new__(cls, name, bases, dict(attrs, _meta=options))
|
||||||
|
|
||||||
def __str__(cls):
|
def __str__(cls): # noqa: N802
|
||||||
return cls._meta.name
|
return cls._meta.name
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import six
|
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 .abstracttype import AbstractTypeMeta
|
from .abstracttype import AbstractTypeMeta
|
||||||
from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs
|
from .options import Options
|
||||||
|
from .utils import (get_fields_in_type, merge_fields_in_attrs,
|
||||||
|
yank_fields_from_attrs)
|
||||||
|
|
||||||
|
|
||||||
class InterfaceMeta(AbstractTypeMeta):
|
class InterfaceMeta(AbstractTypeMeta):
|
||||||
|
@ -29,7 +29,7 @@ class InterfaceMeta(AbstractTypeMeta):
|
||||||
|
|
||||||
return type.__new__(cls, name, bases, dict(attrs, _meta=options))
|
return type.__new__(cls, name, bases, dict(attrs, _meta=options))
|
||||||
|
|
||||||
def __str__(cls):
|
def __str__(cls): # noqa: N802
|
||||||
return cls._meta.name
|
return cls._meta.name
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
import six
|
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 .abstracttype import AbstractTypeMeta
|
from .abstracttype import AbstractTypeMeta
|
||||||
from .utils import get_fields_in_type, yank_fields_from_attrs, merge_fields_in_attrs
|
|
||||||
from .interface import Interface
|
from .interface import Interface
|
||||||
|
from .options import Options
|
||||||
|
from .utils import (get_fields_in_type, merge_fields_in_attrs,
|
||||||
|
yank_fields_from_attrs)
|
||||||
|
|
||||||
|
|
||||||
class ObjectTypeMeta(AbstractTypeMeta):
|
class ObjectTypeMeta(AbstractTypeMeta):
|
||||||
|
@ -45,11 +46,12 @@ class ObjectTypeMeta(AbstractTypeMeta):
|
||||||
|
|
||||||
return cls
|
return cls
|
||||||
|
|
||||||
def __str__(cls):
|
def __str__(cls): # noqa: N802
|
||||||
return cls._meta.name
|
return cls._meta.name
|
||||||
|
|
||||||
|
|
||||||
class ObjectType(six.with_metaclass(ObjectTypeMeta)):
|
class ObjectType(six.with_metaclass(ObjectTypeMeta)):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def is_type_of(cls, root, context, info):
|
def is_type_of(cls, root, context, info):
|
||||||
if isinstance(root, cls):
|
if isinstance(root, cls):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
|
||||||
from ..utils.props import props
|
from ..utils.props import props
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from graphql.language.ast import BooleanValue, FloatValue, IntValue, StringValue
|
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
|
||||||
|
StringValue)
|
||||||
|
|
||||||
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
|
||||||
|
@ -25,7 +26,7 @@ class ScalarTypeMeta(type):
|
||||||
|
|
||||||
return super_new(cls, name, bases, dict(attrs, _meta=options))
|
return super_new(cls, name, bases, dict(attrs, _meta=options))
|
||||||
|
|
||||||
def __str__(cls):
|
def __str__(cls): # noqa: N802
|
||||||
return cls._meta.name
|
return cls._meta.name
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import inspect
|
|
||||||
|
|
||||||
from graphql import GraphQLSchema, MiddlewareManager, graphql, is_type
|
from graphql import GraphQLSchema, MiddlewareManager, graphql, is_type
|
||||||
|
from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective,
|
||||||
|
GraphQLSkipDirective)
|
||||||
|
from graphql.type.introspection import IntrospectionSchema
|
||||||
from graphql.utils.introspection_query import introspection_query
|
from graphql.utils.introspection_query import introspection_query
|
||||||
from graphql.utils.schema_printer import print_schema
|
from graphql.utils.schema_printer import print_schema
|
||||||
|
|
||||||
|
from .typemap import TypeMap, is_graphene_type
|
||||||
|
|
||||||
|
|
||||||
from .objecttype import ObjectType
|
|
||||||
from .structures import List, NonNull
|
|
||||||
from .scalars import Scalar, String
|
|
||||||
# from ..utils.get_graphql_type import get_graphql_type
|
# from ..utils.get_graphql_type import get_graphql_type
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,15 +17,10 @@ from .scalars import Scalar, String
|
||||||
# from collections import defaultdict
|
# from collections import defaultdict
|
||||||
|
|
||||||
|
|
||||||
from graphql.type.directives import (GraphQLDirective, GraphQLIncludeDirective,
|
|
||||||
GraphQLSkipDirective)
|
|
||||||
from graphql.type.introspection import IntrospectionSchema
|
|
||||||
from .typemap import TypeMap, is_graphene_type
|
|
||||||
|
|
||||||
|
|
||||||
class Schema(GraphQLSchema):
|
class Schema(GraphQLSchema):
|
||||||
|
|
||||||
def __init__(self, query=None, mutation=None, subscription=None, directives=None, types=None, executor=None, middlewares=None):
|
def __init__(self, query=None, mutation=None, subscription=None,
|
||||||
|
directives=None, types=None, executor=None, middlewares=None):
|
||||||
self._query = query
|
self._query = query
|
||||||
self._mutation = mutation
|
self._mutation = mutation
|
||||||
self._subscription = subscription
|
self._subscription = subscription
|
||||||
|
|
|
@ -16,10 +16,12 @@ class Structure(UnmountedType):
|
||||||
|
|
||||||
|
|
||||||
class List(Structure):
|
class List(Structure):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '[{}]'.format(self.of_type)
|
return '[{}]'.format(self.of_type)
|
||||||
|
|
||||||
|
|
||||||
class NonNull(Structure):
|
class NonNull(Structure):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '{}!'.format(self.of_type)
|
return '{}!'.format(self.of_type)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
from ..field import Field
|
|
||||||
from ..abstracttype import AbstractType
|
from ..abstracttype import AbstractType
|
||||||
|
from ..field import Field
|
||||||
from ..unmountedtype import UnmountedType
|
from ..unmountedtype import UnmountedType
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +9,7 @@ class MyType(object):
|
||||||
|
|
||||||
|
|
||||||
class MyScalar(UnmountedType):
|
class MyScalar(UnmountedType):
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return MyType
|
return MyType
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
from py.test import raises
|
|
||||||
|
|
||||||
from ..abstracttype import AbstractType
|
from ..abstracttype import AbstractType
|
||||||
from ..objecttype import ObjectType
|
from ..argument import Argument
|
||||||
from ..interface import Interface
|
from ..enum import Enum
|
||||||
from ..union import Union
|
|
||||||
from ..scalars import String, Int, Boolean
|
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ..inputfield import InputField
|
from ..inputfield import InputField
|
||||||
from ..structures import List, NonNull
|
|
||||||
from ..enum import Enum
|
|
||||||
from ..argument import Argument
|
|
||||||
from ..inputobjecttype import InputObjectType
|
from ..inputobjecttype import InputObjectType
|
||||||
|
from ..interface import Interface
|
||||||
|
from ..objecttype import ObjectType
|
||||||
|
from ..scalars import Boolean, Int, String
|
||||||
from ..schema import Schema
|
from ..schema import Schema
|
||||||
|
from ..structures import List, NonNull
|
||||||
|
from ..union import Union
|
||||||
|
|
||||||
|
|
||||||
class Image(ObjectType):
|
class Image(ObjectType):
|
||||||
|
@ -60,6 +57,7 @@ class MyInterface(Interface):
|
||||||
|
|
||||||
|
|
||||||
class MyUnion(Union):
|
class MyUnion(Union):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
types = (Article, )
|
types = (Article, )
|
||||||
|
|
||||||
|
@ -145,6 +143,7 @@ def test_includes_interfaces_thunk_subtypes_in_the_type_map():
|
||||||
f = Int()
|
f = Int()
|
||||||
|
|
||||||
class SomeSubtype(ObjectType):
|
class SomeSubtype(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (SomeInterface, )
|
interfaces = (SomeInterface, )
|
||||||
|
|
||||||
|
@ -167,6 +166,7 @@ def test_includes_types_in_union():
|
||||||
b = String()
|
b = String()
|
||||||
|
|
||||||
class MyUnion(Union):
|
class MyUnion(Union):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
types = (SomeType, OtherType)
|
types = (SomeType, OtherType)
|
||||||
|
|
||||||
|
@ -189,6 +189,7 @@ def test_maps_enum():
|
||||||
b = String()
|
b = String()
|
||||||
|
|
||||||
class MyUnion(Union):
|
class MyUnion(Union):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
types = (SomeType, OtherType)
|
types = (SomeType, OtherType)
|
||||||
|
|
||||||
|
@ -208,6 +209,7 @@ def test_includes_interfaces_subtypes_in_the_type_map():
|
||||||
f = Int()
|
f = Int()
|
||||||
|
|
||||||
class SomeSubtype(ObjectType):
|
class SomeSubtype(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (SomeInterface, )
|
interfaces = (SomeInterface, )
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ def test_enum_construction():
|
||||||
|
|
||||||
def test_enum_construction_meta():
|
def test_enum_construction_meta():
|
||||||
class RGB(Enum):
|
class RGB(Enum):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = 'RGBEnum'
|
name = 'RGBEnum'
|
||||||
description = 'Description'
|
description = 'Description'
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from ..argument import Argument
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ..structures import NonNull
|
from ..structures import NonNull
|
||||||
from ..argument import Argument
|
|
||||||
|
|
||||||
|
|
||||||
class MyInstance(object):
|
class MyInstance(object):
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
from ..abstracttype import AbstractType
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ..inputfield import InputField
|
from ..inputfield import InputField
|
||||||
from ..inputobjecttype import InputObjectType
|
from ..inputobjecttype import InputObjectType
|
||||||
from ..unmountedtype import UnmountedType
|
from ..unmountedtype import UnmountedType
|
||||||
from ..abstracttype import AbstractType
|
|
||||||
|
|
||||||
|
|
||||||
class MyType(object):
|
class MyType(object):
|
||||||
|
@ -12,6 +11,7 @@ class MyType(object):
|
||||||
|
|
||||||
|
|
||||||
class MyScalar(UnmountedType):
|
class MyScalar(UnmountedType):
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return MyType
|
return MyType
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
from ..abstracttype import AbstractType
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ..interface import Interface
|
from ..interface import Interface
|
||||||
from ..unmountedtype import UnmountedType
|
from ..unmountedtype import UnmountedType
|
||||||
from ..abstracttype import AbstractType
|
|
||||||
|
|
||||||
|
|
||||||
class MyType(object):
|
class MyType(object):
|
||||||
|
@ -11,6 +10,7 @@ class MyType(object):
|
||||||
|
|
||||||
|
|
||||||
class MyScalar(UnmountedType):
|
class MyScalar(UnmountedType):
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return MyType
|
return MyType
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ..field import Field
|
|
||||||
from ..mutation import Mutation
|
from ..mutation import Mutation
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..scalars import String
|
|
||||||
|
|
||||||
|
|
||||||
def test_generate_mutation_no_args():
|
def test_generate_mutation_no_args():
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from ..abstracttype import AbstractType
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
|
from ..interface import Interface
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..unmountedtype import UnmountedType
|
from ..unmountedtype import UnmountedType
|
||||||
from ..abstracttype import AbstractType
|
|
||||||
from ..interface import Interface
|
|
||||||
|
|
||||||
|
|
||||||
class MyType(Interface):
|
class MyType(Interface):
|
||||||
|
@ -21,6 +21,7 @@ class MyInterface(Interface):
|
||||||
|
|
||||||
|
|
||||||
class ContainerWithInterface(ObjectType):
|
class ContainerWithInterface(ObjectType):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
interfaces = (MyInterface, )
|
interfaces = (MyInterface, )
|
||||||
field1 = Field(MyType)
|
field1 = Field(MyType)
|
||||||
|
@ -28,6 +29,7 @@ class ContainerWithInterface(ObjectType):
|
||||||
|
|
||||||
|
|
||||||
class MyScalar(UnmountedType):
|
class MyScalar(UnmountedType):
|
||||||
|
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
return MyType
|
return MyType
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
from py.test import raises
|
|
||||||
from graphql import MiddlewareManager
|
|
||||||
|
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..scalars import String, Int, Boolean
|
from ..scalars import String
|
||||||
from ..field import Field
|
|
||||||
from ..structures import List
|
|
||||||
|
|
||||||
from ..schema import Schema
|
from ..schema import Schema
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from ..scalars import (Boolean, Float, Int, String)
|
from ..scalars import Boolean, Float, Int, String
|
||||||
|
|
||||||
|
|
||||||
def test_serializes_output_int():
|
def test_serializes_output_int():
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import pytest
|
|
||||||
|
|
||||||
from ..objecttype import ObjectType
|
from graphql.type import (GraphQLArgument, GraphQLEnumType, GraphQLEnumValue,
|
||||||
from ..union import Union
|
GraphQLField, GraphQLObjectType, GraphQLString)
|
||||||
from ..field import Field
|
|
||||||
from ..dynamic import Dynamic
|
from ..dynamic import Dynamic
|
||||||
from ..enum import Enum
|
from ..enum import Enum
|
||||||
from ..typemap import TypeMap
|
from ..field import Field
|
||||||
|
from ..objecttype import ObjectType
|
||||||
from ..scalars import String
|
from ..scalars import String
|
||||||
|
from ..typemap import TypeMap
|
||||||
|
|
||||||
from graphql.type import GraphQLEnumType, GraphQLEnumValue, GraphQLObjectType, GraphQLField, GraphQLArgument, GraphQLString
|
|
||||||
|
|
||||||
|
|
||||||
def test_enum():
|
def test_enum():
|
||||||
|
|
|
@ -25,6 +25,7 @@ def test_generate_union():
|
||||||
|
|
||||||
def test_generate_union_with_meta():
|
def test_generate_union_with_meta():
|
||||||
class MyUnion(Union):
|
class MyUnion(Union):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
name = 'MyOtherUnion'
|
name = 'MyOtherUnion'
|
||||||
description = 'Documentation'
|
description = 'Documentation'
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
import inspect
|
import inspect
|
||||||
from functools import partial
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
|
from graphql import (GraphQLArgument, GraphQLBoolean, GraphQLField,
|
||||||
|
GraphQLFloat, GraphQLID, GraphQLInputObjectField,
|
||||||
|
GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLString)
|
||||||
|
from graphql.type import GraphQLEnumValue
|
||||||
from graphql.type.typemap import GraphQLTypeMap
|
from graphql.type.typemap import GraphQLTypeMap
|
||||||
|
|
||||||
from .objecttype import ObjectType
|
|
||||||
from .interface import Interface
|
|
||||||
from .union import Union
|
|
||||||
from .inputobjecttype import InputObjectType
|
|
||||||
from .structures import List, NonNull
|
|
||||||
from .enum import Enum
|
|
||||||
from .scalars import Scalar, String, Boolean, Int, Float, ID
|
|
||||||
from .dynamic import Dynamic
|
|
||||||
|
|
||||||
from graphql import GraphQLString, GraphQLField, GraphQLList, GraphQLBoolean, GraphQLInt, GraphQLFloat, GraphQLID, GraphQLNonNull, GraphQLInputObjectField, GraphQLArgument
|
|
||||||
from graphql.type import GraphQLEnumValue
|
|
||||||
|
|
||||||
from ..utils.str_converters import to_camel_case
|
from ..utils.str_converters import to_camel_case
|
||||||
|
from .dynamic import Dynamic
|
||||||
|
from .enum import Enum
|
||||||
|
from .inputobjecttype import InputObjectType
|
||||||
|
from .interface import Interface
|
||||||
|
from .objecttype import ObjectType
|
||||||
|
from .scalars import ID, Boolean, Float, Int, Scalar, String
|
||||||
|
from .structures import List, NonNull
|
||||||
|
from .union import Union
|
||||||
|
|
||||||
|
|
||||||
def is_graphene_type(_type):
|
def is_graphene_type(_type):
|
||||||
|
@ -252,11 +252,11 @@ class TypeMap(GraphQLTypeMap):
|
||||||
return partial(cls.default_resolver, name)
|
return partial(cls.default_resolver, name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_field_type(self, map, type):
|
def get_field_type(cls, map, type):
|
||||||
if isinstance(type, List):
|
if isinstance(type, List):
|
||||||
return GraphQLList(self.get_field_type(map, type.of_type))
|
return GraphQLList(cls.get_field_type(map, type.of_type))
|
||||||
if isinstance(type, NonNull):
|
if isinstance(type, NonNull):
|
||||||
return GraphQLNonNull(self.get_field_type(map, type.of_type))
|
return GraphQLNonNull(cls.get_field_type(map, type.of_type))
|
||||||
if inspect.isfunction(type):
|
if inspect.isfunction(type):
|
||||||
type = type()
|
type = type()
|
||||||
return map.get(type._meta.name)
|
return map.get(type._meta.name)
|
||||||
|
|
|
@ -26,7 +26,7 @@ class UnionMeta(type):
|
||||||
|
|
||||||
return type.__new__(cls, name, bases, dict(attrs, _meta=options))
|
return type.__new__(cls, name, bases, dict(attrs, _meta=options))
|
||||||
|
|
||||||
def __str__(cls):
|
def __str__(cls): # noqa: N805
|
||||||
return cls._meta.name
|
return cls._meta.name
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ class UnmountedType(OrderedType):
|
||||||
def get_type(self):
|
def get_type(self):
|
||||||
raise NotImplementedError("get_type not implemented in {}".format(self))
|
raise NotImplementedError("get_type not implemented in {}".format(self))
|
||||||
|
|
||||||
def Field(self):
|
def Field(self): # noqa: N802
|
||||||
'''
|
'''
|
||||||
Mount the UnmountedType as Field
|
Mount the UnmountedType as Field
|
||||||
'''
|
'''
|
||||||
|
@ -35,7 +35,7 @@ class UnmountedType(OrderedType):
|
||||||
**self.kwargs
|
**self.kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def InputField(self):
|
def InputField(self): # noqa: N802
|
||||||
'''
|
'''
|
||||||
Mount the UnmountedType as InputField
|
Mount the UnmountedType as InputField
|
||||||
'''
|
'''
|
||||||
|
@ -47,7 +47,7 @@ class UnmountedType(OrderedType):
|
||||||
**self.kwargs
|
**self.kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
def Argument(self):
|
def Argument(self): # noqa: N802
|
||||||
'''
|
'''
|
||||||
Mount the UnmountedType as Argument
|
Mount the UnmountedType as Argument
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from .unmountedtype import UnmountedType
|
|
||||||
from .field import Field
|
|
||||||
from .dynamic import Dynamic
|
from .dynamic import Dynamic
|
||||||
|
from .field import Field
|
||||||
from .inputfield import InputField
|
from .inputfield import InputField
|
||||||
|
from .unmountedtype import UnmountedType
|
||||||
|
|
||||||
|
|
||||||
def merge_fields_in_attrs(bases, attrs):
|
def merge_fields_in_attrs(bases, attrs):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user