mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-22 09:36:44 +03:00
Autolint all the files
This commit is contained in:
parent
76ecd895e1
commit
c74a75133e
|
@ -1,10 +1,9 @@
|
|||
|
||||
from ..data import setup
|
||||
from ..schema import schema, Droid
|
||||
from ..schema import Droid
|
||||
|
||||
|
||||
def test_query_types():
|
||||
graphql_type = Droid._meta.graphql_type
|
||||
fields = graphql_type.get_fields()
|
||||
assert fields['friends'].parent == Droid
|
||||
assert fields
|
||||
assert fields
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import graphene
|
||||
from graphene import implements, relay, resolve_only_args
|
||||
from graphene import relay, resolve_only_args
|
||||
|
||||
from .data import create_ship, get_empire, get_faction, get_rebels, get_ship
|
||||
|
||||
|
@ -65,5 +65,4 @@ class Mutation(graphene.ObjectType):
|
|||
introduce_ship = IntroduceShip.Field()
|
||||
|
||||
|
||||
|
||||
schema = graphene.Schema(query=Query, mutation=Mutation)
|
||||
|
|
|
@ -14,4 +14,22 @@ from .types import (
|
|||
)
|
||||
from .utils.resolve_only_args import resolve_only_args
|
||||
|
||||
__all__ = ['ObjectType', 'InputObjectType', 'Interface', 'implements', 'Field', 'InputField', 'Schema', 'Scalar', 'String', 'ID', 'Int', 'Float', 'Enum', 'Boolean', 'List','NonNull', 'Argument','resolve_only_args']
|
||||
__all__ = [
|
||||
'ObjectType',
|
||||
'InputObjectType',
|
||||
'Interface',
|
||||
'implements',
|
||||
'Field',
|
||||
'InputField',
|
||||
'Schema',
|
||||
'Scalar',
|
||||
'String',
|
||||
'ID',
|
||||
'Int',
|
||||
'Float',
|
||||
'Enum',
|
||||
'Boolean',
|
||||
'List',
|
||||
'NonNull',
|
||||
'Argument',
|
||||
'resolve_only_args']
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
from .node import Node
|
||||
from .mutation import ClientIDMutation
|
||||
from .connection import Connection
|
||||
|
||||
__all__ = [
|
||||
'Node',
|
||||
'ClientIDMutation',
|
||||
'Connection',
|
||||
]
|
||||
|
|
|
@ -1,23 +1,17 @@
|
|||
import re
|
||||
from collections import Iterable
|
||||
|
||||
import six
|
||||
|
||||
from graphql_relay import connection_definitions, connection_from_list
|
||||
|
||||
from ..types.field import Field
|
||||
from ..types.objecttype import ObjectType, ObjectTypeMeta
|
||||
|
||||
from ..utils.props import props
|
||||
|
||||
from ..types.field import Field, InputField
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.props import props
|
||||
|
||||
|
||||
from ..types.objecttype import ObjectType
|
||||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..types.options import Options
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..utils.props import props
|
||||
|
||||
|
||||
class ConnectionMeta(ObjectTypeMeta):
|
||||
|
@ -69,7 +63,7 @@ class Connection(six.with_metaclass(ConnectionMeta, ObjectType)):
|
|||
|
||||
class IterableConnectionField(Field):
|
||||
# def __init__(self, type, *args, **kwargs):
|
||||
# if
|
||||
# if
|
||||
|
||||
def resolver(self, root, args, context, info):
|
||||
iterable = super(ConnectionField, self).resolver(root, args, context, info)
|
||||
|
|
|
@ -1,19 +1,18 @@
|
|||
from functools import partial
|
||||
|
||||
import six
|
||||
|
||||
from graphql_relay import mutation_with_client_mutation_id
|
||||
|
||||
from ..types.mutation import Mutation, MutationMeta
|
||||
from ..types.inputobjecttype import InputObjectType
|
||||
from ..types.field import Field, InputField
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.props import props
|
||||
|
||||
|
||||
from ..types.inputobjecttype import InputObjectType
|
||||
from ..types.mutation import Mutation, MutationMeta
|
||||
from ..types.objecttype import ObjectType
|
||||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..types.options import Options
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..utils.props import props
|
||||
|
||||
|
||||
class ClientIDMutationMeta(MutationMeta):
|
||||
|
@ -41,7 +40,8 @@ class ClientIDMutationMeta(MutationMeta):
|
|||
output_fields = copy_fields(Field, get_fields(ObjectType, attrs, bases))
|
||||
|
||||
mutate_and_get_payload = getattr(cls, 'mutate_and_get_payload', None)
|
||||
assert mutate_and_get_payload, "{}.mutate_and_get_payload method is required in a ClientIDMutation ObjectType.".format(cls.__name__)
|
||||
assert mutate_and_get_payload, "{}.mutate_and_get_payload method is required in a ClientIDMutation ObjectType.".format(
|
||||
cls.__name__)
|
||||
|
||||
field = mutation_with_client_mutation_id(
|
||||
name=options.name or cls.__name__,
|
||||
|
@ -55,5 +55,6 @@ class ClientIDMutationMeta(MutationMeta):
|
|||
|
||||
|
||||
class ClientIDMutation(six.with_metaclass(ClientIDMutationMeta, Mutation)):
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
from functools import partial
|
||||
|
||||
import six
|
||||
from graphql_relay import node_definitions, from_global_id, to_global_id
|
||||
|
||||
from graphql_relay import from_global_id, node_definitions, to_global_id
|
||||
|
||||
from ..types.field import Field
|
||||
from ..types.options import Options
|
||||
from ..types.objecttype import ObjectTypeMeta
|
||||
from ..types.interface import Interface
|
||||
from ..types.objecttype import ObjectTypeMeta
|
||||
from ..types.options import Options
|
||||
|
||||
|
||||
class NodeMeta(ObjectTypeMeta):
|
||||
|
@ -22,7 +24,12 @@ class NodeMeta(ObjectTypeMeta):
|
|||
id_resolver=id_resolver,
|
||||
)
|
||||
cls._meta = Options(None, graphql_type=node_interface)
|
||||
cls.Field = partial(Field.copy_and_extend, node_field, type=node_field.type, parent=cls, _creation_counter=None)
|
||||
cls.Field = partial(
|
||||
Field.copy_and_extend,
|
||||
node_field,
|
||||
type=node_field.type,
|
||||
parent=cls,
|
||||
_creation_counter=None)
|
||||
else:
|
||||
# The interface provided by node_definitions is not an instance
|
||||
# of GrapheneInterfaceType, so it will have no graphql_type,
|
||||
|
@ -71,6 +78,8 @@ class Node(six.with_metaclass(NodeMeta, Interface)):
|
|||
in it
|
||||
'''
|
||||
if cls.require_get_node():
|
||||
assert hasattr(object_type, 'get_node'), '{}.get_node method is required by the Node interface.'.format(object_type.__name__)
|
||||
assert hasattr(
|
||||
object_type, 'get_node'), '{}.get_node method is required by the Node interface.'.format(
|
||||
object_type.__name__)
|
||||
|
||||
return super(Node, cls).implements(object_type)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from ...types import ObjectType, Schema
|
||||
from ...types.field import Field
|
||||
from ...types.scalars import String
|
||||
from ..connection import Connection
|
||||
from ..node import Node
|
||||
from ...types import ObjectType, Schema
|
||||
from ...types.scalars import String
|
||||
from ...types.field import Field
|
||||
|
||||
|
||||
class MyObject(Node, ObjectType):
|
||||
|
@ -16,6 +15,7 @@ class MyObject(Node, ObjectType):
|
|||
|
||||
|
||||
class MyObjectConnection(Connection):
|
||||
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import pytest
|
||||
|
||||
from graphql_relay import to_global_id
|
||||
|
||||
from ..mutation import ClientIDMutation
|
||||
from ...types import ObjectType, Schema, implements
|
||||
from ...types import ObjectType, Schema
|
||||
from ...types.scalars import String
|
||||
from ..mutation import ClientIDMutation
|
||||
|
||||
|
||||
class SaySomething(ClientIDMutation):
|
||||
|
||||
class Input:
|
||||
what = String()
|
||||
phrase = String()
|
||||
|
@ -33,7 +32,8 @@ def test_no_mutate_and_get_payload():
|
|||
class MyMutation(ClientIDMutation):
|
||||
pass
|
||||
|
||||
assert "MyMutation.mutate_and_get_payload method is required in a ClientIDMutation ObjectType." == str(excinfo.value)
|
||||
assert "MyMutation.mutate_and_get_payload method is required in a ClientIDMutation ObjectType." == str(
|
||||
excinfo.value)
|
||||
|
||||
|
||||
def test_node_good():
|
||||
|
@ -81,4 +81,4 @@ def test_node_query():
|
|||
# first: String
|
||||
# node(id: ID!): Node
|
||||
# }
|
||||
# """.lstrip()
|
||||
# """.lstrip()
|
||||
|
|
|
@ -2,9 +2,9 @@ import pytest
|
|||
|
||||
from graphql_relay import to_global_id
|
||||
|
||||
from ..node import Node
|
||||
from ...types import ObjectType, Schema, implements
|
||||
from ...types import ObjectType, Schema
|
||||
from ...types.scalars import String
|
||||
from ..node import Node
|
||||
|
||||
|
||||
class MyNode(Node, ObjectType):
|
||||
|
@ -59,6 +59,7 @@ def test_node_query_incorrect_id():
|
|||
assert not executed.errors
|
||||
assert executed.data == {'node': None}
|
||||
|
||||
|
||||
def test_str_schema():
|
||||
assert str(schema) == """
|
||||
schema {
|
||||
|
@ -78,4 +79,4 @@ type RootQuery {
|
|||
first: String
|
||||
node(id: ID!): Node
|
||||
}
|
||||
""".lstrip()
|
||||
""".lstrip()
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
from graphql import graphql
|
||||
|
||||
from ...types import ObjectType, Schema
|
||||
from ...types.scalars import Int, String
|
||||
from ..node import Node
|
||||
from ...types import ObjectType, Schema, implements
|
||||
from ...types.scalars import String, Int
|
||||
|
||||
|
||||
class CustomNode(Node):
|
||||
|
||||
@staticmethod
|
||||
def to_global_id(type, id):
|
||||
return id
|
||||
|
@ -222,20 +223,20 @@ def test_have_correct_node_interface():
|
|||
'''
|
||||
expected = {
|
||||
'__type': {
|
||||
'name': 'Node',
|
||||
'kind': 'INTERFACE',
|
||||
'fields': [
|
||||
{
|
||||
'name': 'id',
|
||||
'type': {
|
||||
'kind': 'NON_NULL',
|
||||
'ofType': {
|
||||
'name': 'ID',
|
||||
'kind': 'SCALAR'
|
||||
'name': 'Node',
|
||||
'kind': 'INTERFACE',
|
||||
'fields': [
|
||||
{
|
||||
'name': 'id',
|
||||
'type': {
|
||||
'kind': 'NON_NULL',
|
||||
'ofType': {
|
||||
'name': 'ID',
|
||||
'kind': 'SCALAR'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
result = graphql(schema, query)
|
||||
|
@ -271,29 +272,29 @@ def test_has_correct_node_root_field():
|
|||
'''
|
||||
expected = {
|
||||
'__schema': {
|
||||
'queryType': {
|
||||
'fields': [
|
||||
{
|
||||
'name': 'node',
|
||||
'type': {
|
||||
'name': 'Node',
|
||||
'kind': 'INTERFACE'
|
||||
},
|
||||
'args': [
|
||||
{
|
||||
'name': 'id',
|
||||
'type': {
|
||||
'kind': 'NON_NULL',
|
||||
'ofType': {
|
||||
'name': 'ID',
|
||||
'kind': 'SCALAR'
|
||||
}
|
||||
'queryType': {
|
||||
'fields': [
|
||||
{
|
||||
'name': 'node',
|
||||
'type': {
|
||||
'name': 'Node',
|
||||
'kind': 'INTERFACE'
|
||||
},
|
||||
'args': [
|
||||
{
|
||||
'name': 'id',
|
||||
'type': {
|
||||
'kind': 'NON_NULL',
|
||||
'ofType': {
|
||||
'name': 'ID',
|
||||
'kind': 'SCALAR'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result = graphql(schema, query)
|
||||
|
|
|
@ -8,4 +8,21 @@ from .field import Field, InputField
|
|||
from .argument import Argument
|
||||
from .inputobjecttype import InputObjectType
|
||||
|
||||
__all__ = ['ObjectType', 'InputObjectType', 'Interface', 'implements', 'Enum', 'Field', 'InputField', 'Schema', 'Scalar', 'String', 'ID', 'Int', 'Float', 'Boolean', 'List', 'NonNull', 'Argument']
|
||||
__all__ = [
|
||||
'ObjectType',
|
||||
'InputObjectType',
|
||||
'Interface',
|
||||
'implements',
|
||||
'Enum',
|
||||
'Field',
|
||||
'InputField',
|
||||
'Schema',
|
||||
'Scalar',
|
||||
'String',
|
||||
'ID',
|
||||
'Int',
|
||||
'Float',
|
||||
'Boolean',
|
||||
'List',
|
||||
'NonNull',
|
||||
'Argument']
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import copy
|
||||
from collections import OrderedDict
|
||||
import inspect
|
||||
from collections import OrderedDict
|
||||
from itertools import chain
|
||||
|
||||
from graphql import GraphQLArgument
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
class GrapheneGraphQLType(object):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.graphene_type = kwargs.pop('graphene_type')
|
||||
super(GrapheneGraphQLType, self).__init__(*args, **kwargs)
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
import six
|
||||
from graphql.type import GraphQLEnumType, GraphQLEnumValue
|
||||
from collections import OrderedDict
|
||||
|
||||
import six
|
||||
|
||||
from graphql.type import GraphQLEnumType, GraphQLEnumValue
|
||||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .options import Options
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
try:
|
||||
from enum import Enum as PyEnum
|
||||
except ImportError:
|
||||
from ..utils.enum import Enum as PyEnum
|
||||
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType):
|
||||
|
@ -65,6 +68,7 @@ class EnumTypeMeta(type):
|
|||
|
||||
|
||||
class Enum(six.with_metaclass(EnumTypeMeta, UnmountedType)):
|
||||
|
||||
@classmethod
|
||||
def from_enum(cls, python_enum):
|
||||
class Meta:
|
||||
|
|
|
@ -9,6 +9,7 @@ from .argument import to_arguments
|
|||
|
||||
|
||||
class AbstractField(object):
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._name or self.attname and to_camel_case(self.attname)
|
||||
|
@ -39,7 +40,8 @@ class AbstractField(object):
|
|||
|
||||
class Field(AbstractField, GraphQLField, OrderedType):
|
||||
|
||||
def __init__(self, type, args=None, resolver=None, source=None, deprecation_reason=None, name=None, description=None, required=False, _creation_counter=None, **extra_args):
|
||||
def __init__(self, type, args=None, resolver=None, source=None, deprecation_reason=None,
|
||||
name=None, description=None, required=False, _creation_counter=None, **extra_args):
|
||||
self.name = name
|
||||
self.attname = None
|
||||
self.parent = None
|
||||
|
@ -74,8 +76,7 @@ class Field(AbstractField, GraphQLField, OrderedType):
|
|||
|
||||
@property
|
||||
def resolver(self):
|
||||
from .objecttype import ObjectType
|
||||
from .interface import GrapheneInterfaceType
|
||||
pass
|
||||
|
||||
resolver = getattr(self.parent, 'resolve_{}'.format(self.attname), None)
|
||||
|
||||
|
@ -105,7 +106,7 @@ class Field(AbstractField, GraphQLField, OrderedType):
|
|||
# root = self.parent()
|
||||
# return resolver(root, *args, **kwargs)
|
||||
|
||||
return self._resolver or resolver # resolver_wrapper
|
||||
return self._resolver or resolver # resolver_wrapper
|
||||
|
||||
@resolver.setter
|
||||
def resolver(self, resolver):
|
||||
|
@ -115,7 +116,9 @@ class Field(AbstractField, GraphQLField, OrderedType):
|
|||
return self.copy_and_extend(self)
|
||||
|
||||
@classmethod
|
||||
def copy_and_extend(cls, field, type=None, args=None, resolver=None, source=None, deprecation_reason=None, name=None, description=None, required=False, _creation_counter=False, parent=None, attname=None, **extra_args):
|
||||
def copy_and_extend(
|
||||
cls, field, type=None, args=None, resolver=None, source=None, deprecation_reason=None, name=None,
|
||||
description=None, required=False, _creation_counter=False, parent=None, attname=None, **extra_args):
|
||||
if isinstance(field, Field):
|
||||
type = type or field._type
|
||||
resolver = resolver or field._resolver
|
||||
|
@ -185,7 +188,8 @@ class InputField(AbstractField, GraphQLInputObjectField, OrderedType):
|
|||
return self.copy_and_extend(self)
|
||||
|
||||
@classmethod
|
||||
def copy_and_extend(cls, field, type=None, default_value=None, description=None, name=None, required=False, parent=None, attname=None, _creation_counter=False):
|
||||
def copy_and_extend(cls, field, type=None, default_value=None, description=None, name=None,
|
||||
required=False, parent=None, attname=None, _creation_counter=False):
|
||||
if isinstance(field, Field):
|
||||
type = type or field._type
|
||||
name = name or field._name
|
||||
|
|
|
@ -2,14 +2,14 @@ import six
|
|||
|
||||
from graphql import GraphQLInputObjectType
|
||||
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .interface import attrs_without_fields
|
||||
from .unmountedtype import UnmountedType
|
||||
from .options import Options
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .field import InputField
|
||||
from .interface import attrs_without_fields
|
||||
from .options import Options
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class GrapheneInputObjectType(GrapheneGraphQLType, GraphQLInputObjectType):
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import six
|
||||
|
||||
from graphql import GraphQLInterfaceType
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .options import Options
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..utils.get_fields import get_fields
|
||||
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .field import Field
|
||||
from .options import Options
|
||||
|
||||
|
||||
class GrapheneInterfaceType(GrapheneGraphQLType, GraphQLInterfaceType):
|
||||
|
@ -72,4 +73,3 @@ class Interface(six.with_metaclass(InterfaceTypeMeta)):
|
|||
For example, if we want to check that the ObjectType have some required things
|
||||
in it like Node.get_node
|
||||
'''
|
||||
pass
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from functools import partial
|
||||
|
||||
import six
|
||||
|
||||
from .objecttype import ObjectTypeMeta, ObjectType
|
||||
from .field import Field
|
||||
|
||||
from ..utils.props import props
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..utils.props import props
|
||||
from .field import Field
|
||||
from .objecttype import ObjectType, ObjectTypeMeta
|
||||
|
||||
|
||||
class MutationMeta(ObjectTypeMeta):
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
import copy
|
||||
|
||||
import six
|
||||
|
||||
from graphql import GraphQLObjectType
|
||||
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .interface import GrapheneInterfaceType, InterfaceTypeMeta, Interface, attrs_without_fields
|
||||
from .options import Options
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.copy_fields import copy_fields
|
||||
from ..utils.get_fields import get_fields
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .field import Field
|
||||
from .interface import (GrapheneInterfaceType, Interface, InterfaceTypeMeta,
|
||||
attrs_without_fields)
|
||||
from .options import Options
|
||||
|
||||
|
||||
class GrapheneObjectType(GrapheneGraphQLType, GraphQLObjectType):
|
||||
|
@ -120,6 +122,7 @@ def implements(*interfaces):
|
|||
|
||||
|
||||
class ObjectType(six.with_metaclass(ObjectTypeMeta)):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
# GraphQL ObjectType acting as container
|
||||
args_len = len(args)
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import six
|
||||
from graphql import GraphQLScalarType, GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean, GraphQLID
|
||||
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .unmountedtype import UnmountedType
|
||||
from .options import Options
|
||||
from graphql import (GraphQLBoolean, GraphQLFloat, GraphQLID, GraphQLInt,
|
||||
GraphQLScalarType, GraphQLString)
|
||||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from .definitions import GrapheneGraphQLType
|
||||
from .options import Options
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class GrapheneScalarType(GrapheneGraphQLType, GraphQLScalarType):
|
||||
|
@ -53,7 +55,7 @@ def construct_scalar_class(graphql_type):
|
|||
# class String(Scalar):
|
||||
# class Meta:
|
||||
# graphql_type = graphql_type
|
||||
Meta = type('Meta', (object,), {'graphql_type':graphql_type})
|
||||
Meta = type('Meta', (object,), {'graphql_type': graphql_type})
|
||||
return type(graphql_type.name, (Scalar, ), {'Meta': Meta})
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
from graphql import graphql, GraphQLSchema
|
||||
from graphql import GraphQLSchema, graphql
|
||||
from graphql.utils.introspection_query import introspection_query
|
||||
from graphql.utils.schema_printer import print_schema
|
||||
# from graphql.type.schema import assert_object_implements_interface
|
||||
|
||||
from ..utils.get_graphql_type import get_graphql_type
|
||||
|
||||
|
||||
# from graphql.type.schema import assert_object_implements_interface
|
||||
|
||||
# from collections import defaultdict
|
||||
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ from .unmountedtype import UnmountedType
|
|||
|
||||
|
||||
class Structure(UnmountedType):
|
||||
|
||||
def __init__(self, of_type, *args, **kwargs):
|
||||
super(Structure, self).__init__(*args, **kwargs)
|
||||
self.of_type = of_type
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import pytest
|
||||
import copy
|
||||
|
||||
from graphql import GraphQLString, GraphQLArgument
|
||||
import pytest
|
||||
|
||||
from graphql import GraphQLArgument, GraphQLString
|
||||
|
||||
from ..argument import Argument, to_arguments
|
||||
from ..scalars import String
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from graphql.type import GraphQLEnumType, GraphQLEnumValue
|
||||
|
||||
from ...utils.enum import Enum as PyEnum
|
||||
from ..argument import Argument
|
||||
from ..enum import Enum
|
||||
from ..field import Field
|
||||
from ..argument import Argument
|
||||
from ...utils.enum import Enum as PyEnum
|
||||
|
||||
|
||||
def test_enum_construction():
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import pytest
|
||||
import copy
|
||||
|
||||
from graphql import GraphQLString, GraphQLField, GraphQLInt, GraphQLNonNull
|
||||
import pytest
|
||||
|
||||
from graphql import GraphQLField, GraphQLInt, GraphQLNonNull, GraphQLString
|
||||
|
||||
from ..field import Field
|
||||
from ..argument import Argument
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import String, Int
|
||||
from ..field import Field
|
||||
from ..scalars import Int, String
|
||||
|
||||
|
||||
def test_field():
|
||||
|
@ -33,7 +33,7 @@ def test_field_wrong_name():
|
|||
|
||||
def test_not_source_and_resolver():
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
Field(GraphQLString, source="a", resolver=lambda *_:None)
|
||||
Field(GraphQLString, source="a", resolver=lambda *_: None)
|
||||
|
||||
assert "You cannot have a source and a resolver at the same time" == str(excinfo.value)
|
||||
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
import pytest
|
||||
|
||||
from graphql import GraphQLObjectType, GraphQLField, GraphQLString, GraphQLInputObjectType
|
||||
from graphql import GraphQLInputObjectType, GraphQLString
|
||||
|
||||
from ..objecttype import ObjectType
|
||||
from ..field import InputField
|
||||
from ..inputobjecttype import InputObjectType
|
||||
from ..field import Field, InputField
|
||||
from ..scalars import String
|
||||
|
||||
|
||||
def test_generate_inputobjecttype():
|
||||
class MyObjectType(InputObjectType):
|
||||
'''Documentation'''
|
||||
pass
|
||||
|
||||
graphql_type = MyObjectType._meta.graphql_type
|
||||
assert isinstance(graphql_type, GraphQLInputObjectType)
|
||||
|
@ -21,6 +18,7 @@ def test_generate_inputobjecttype():
|
|||
|
||||
def test_generate_inputobjecttype_with_meta():
|
||||
class MyObjectType(InputObjectType):
|
||||
|
||||
class Meta:
|
||||
name = 'MyOtherObjectType'
|
||||
description = 'Documentation'
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
import pytest
|
||||
|
||||
from graphql import GraphQLInterfaceType, GraphQLField, GraphQLString, GraphQLInterfaceType
|
||||
from graphql import GraphQLField, GraphQLInterfaceType, GraphQLString
|
||||
|
||||
from ..interface import Interface
|
||||
from ..field import Field
|
||||
from ..interface import Interface
|
||||
|
||||
|
||||
def test_generate_interface():
|
||||
class MyInterface(Interface):
|
||||
'''Documentation'''
|
||||
pass
|
||||
|
||||
graphql_type = MyInterface._meta.graphql_type
|
||||
assert isinstance(graphql_type, GraphQLInterfaceType)
|
||||
|
@ -19,6 +18,7 @@ def test_generate_interface():
|
|||
|
||||
def test_generate_interface_with_meta():
|
||||
class MyInterface(Interface):
|
||||
|
||||
class Meta:
|
||||
name = 'MyOtherInterface'
|
||||
description = 'Documentation'
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import pytest
|
||||
|
||||
from graphql import GraphQLObjectType, GraphQLField, GraphQLString, GraphQLInterfaceType
|
||||
from graphql import GraphQLObjectType, GraphQLString
|
||||
|
||||
from ..schema import Schema
|
||||
from ..objecttype import ObjectType
|
||||
from ..mutation import Mutation
|
||||
from ..interface import Interface
|
||||
from ..scalars import String
|
||||
from ..field import Field
|
||||
from ..argument import Argument
|
||||
from ..mutation import Mutation
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import String
|
||||
|
||||
|
||||
def test_generate_mutation_no_args():
|
||||
|
@ -48,6 +45,7 @@ def test_generate_mutation_with_args():
|
|||
|
||||
def test_generate_mutation_with_meta():
|
||||
class MyMutation(Mutation):
|
||||
|
||||
class Meta:
|
||||
name = 'MyOtherMutation'
|
||||
description = 'Documentation'
|
||||
|
@ -64,6 +62,7 @@ def test_generate_mutation_with_meta():
|
|||
|
||||
def test_empty_mutation_has_meta():
|
||||
class MyMutation(Mutation):
|
||||
|
||||
@classmethod
|
||||
def mutate(cls, *args, **kwargs):
|
||||
pass
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import pytest
|
||||
|
||||
from graphql import GraphQLObjectType, GraphQLField, GraphQLString, GraphQLInterfaceType
|
||||
from graphql import (GraphQLField, GraphQLInterfaceType, GraphQLObjectType,
|
||||
GraphQLString)
|
||||
|
||||
from ..schema import Schema
|
||||
from ..objecttype import ObjectType
|
||||
from ..interface import Interface
|
||||
from ..scalars import String
|
||||
from ..field import Field
|
||||
from ..interface import Interface
|
||||
from ..objecttype import ObjectType
|
||||
|
||||
|
||||
class Container(ObjectType):
|
||||
|
@ -17,7 +16,6 @@ class Container(ObjectType):
|
|||
def test_generate_objecttype():
|
||||
class MyObjectType(ObjectType):
|
||||
'''Documentation'''
|
||||
pass
|
||||
|
||||
graphql_type = MyObjectType._meta.graphql_type
|
||||
assert isinstance(graphql_type, GraphQLObjectType)
|
||||
|
@ -27,6 +25,7 @@ def test_generate_objecttype():
|
|||
|
||||
def test_generate_objecttype_with_meta():
|
||||
class MyObjectType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
name = 'MyOtherObjectType'
|
||||
description = 'Documentation'
|
||||
|
@ -139,6 +138,7 @@ def test_objecttype_reuse_graphql_type():
|
|||
})
|
||||
|
||||
class GrapheneObjectType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
graphql_type = MyGraphQLType
|
||||
|
||||
|
@ -169,6 +169,7 @@ def test_objecttype_graphql_interface():
|
|||
})
|
||||
|
||||
class GrapheneObjectType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
interfaces = [MyInterface]
|
||||
|
||||
|
@ -185,6 +186,7 @@ def test_objecttype_graphene_interface():
|
|||
extended = Field(GraphQLString)
|
||||
|
||||
class GrapheneObjectType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
interfaces = [GrapheneInterface]
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import pytest
|
||||
from ..scalars import Scalar, String, Int, Float, Boolean
|
||||
|
||||
from graphene.utils.get_graphql_type import get_graphql_type
|
||||
from graphql import GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLString
|
||||
|
||||
from ..field import Field
|
||||
from ..objecttype import ObjectType
|
||||
|
||||
from graphql import GraphQLString, GraphQLInt, GraphQLFloat, GraphQLBoolean
|
||||
from graphene.utils.get_graphql_type import get_graphql_type
|
||||
from ..scalars import Boolean, Float, Int, Scalar, String
|
||||
|
||||
|
||||
class DatetimeScalar(Scalar):
|
||||
|
||||
def serialize(value):
|
||||
return value.isoformat()
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from ..scalars import String
|
||||
from ..field import Field
|
||||
from ..objecttype import ObjectType
|
||||
from ..interface import Interface
|
||||
from ..structures import List
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import String
|
||||
from ..schema import Schema
|
||||
from ..structures import List
|
||||
|
||||
|
||||
class Character(Interface):
|
||||
|
@ -18,6 +18,7 @@ class Pet(ObjectType):
|
|||
|
||||
# @implements(Character)
|
||||
class Human(ObjectType):
|
||||
|
||||
class Meta:
|
||||
interfaces = [Character]
|
||||
|
||||
|
@ -44,9 +45,11 @@ schema = Schema(query=RootQuery, types=[Human])
|
|||
|
||||
|
||||
def test_schema():
|
||||
executed = schema.execute('{ character {name, bestFriend { name }, friends { name}, ...on Human {pet { type } } } }')
|
||||
executed = schema.execute(
|
||||
'{ character {name, bestFriend { name }, friends { name}, ...on Human {pet { type } } } }')
|
||||
assert not executed.errors
|
||||
assert executed.data == {'character': {'name': 'Harry', 'bestFriend': {'name': 'Best'}, 'friends': [{'name': 'Peter'}], 'pet': {'type': 'Dog'}}}
|
||||
assert executed.data == {'character': {'name': 'Harry', 'bestFriend': {
|
||||
'name': 'Best'}, 'friends': [{'name': 'Peter'}], 'pet': {'type': 'Dog'}}}
|
||||
|
||||
|
||||
def test_schema_introspect():
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from graphql import GraphQLString, GraphQLList, GraphQLNonNull
|
||||
from graphql import GraphQLList, GraphQLNonNull, GraphQLString
|
||||
|
||||
from ..structures import List, NonNull
|
||||
from ..scalars import String
|
||||
from ..field import Field
|
||||
from ..scalars import String
|
||||
from ..structures import List, NonNull
|
||||
|
||||
|
||||
def test_list():
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from .field import Field, InputField
|
||||
from .argument import Argument
|
||||
from ..utils.orderedtype import OrderedType
|
||||
from .argument import Argument
|
||||
from .field import Field, InputField
|
||||
|
||||
|
||||
# UnmountedType ?
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from collections import OrderedDict
|
||||
from ..types.field import Field, InputField
|
||||
|
||||
|
||||
def copy_fields(like, fields, **extra):
|
||||
|
|
|
@ -35,6 +35,7 @@ except NameError:
|
|||
# In Python 3 unicode no longer exists (it's just str)
|
||||
unicode = str
|
||||
|
||||
|
||||
class _RouteClassAttributeToGetattr(object):
|
||||
"""Route attribute access on a class to __getattr__.
|
||||
|
||||
|
@ -44,6 +45,7 @@ class _RouteClassAttributeToGetattr(object):
|
|||
class's __getattr__ method; this is done by raising AttributeError.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, fget=None):
|
||||
self.fget = fget
|
||||
|
||||
|
@ -62,9 +64,9 @@ class _RouteClassAttributeToGetattr(object):
|
|||
def _is_descriptor(obj):
|
||||
"""Returns True if obj is a descriptor, False otherwise."""
|
||||
return (
|
||||
hasattr(obj, '__get__') or
|
||||
hasattr(obj, '__set__') or
|
||||
hasattr(obj, '__delete__'))
|
||||
hasattr(obj, '__get__') or
|
||||
hasattr(obj, '__set__') or
|
||||
hasattr(obj, '__delete__'))
|
||||
|
||||
|
||||
def _is_dunder(name):
|
||||
|
@ -85,6 +87,7 @@ def _is_sunder(name):
|
|||
|
||||
def _make_class_unpicklable(cls):
|
||||
"""Make the given class un-picklable."""
|
||||
|
||||
def _break_on_call_reduce(self, protocol=None):
|
||||
raise TypeError('%r cannot be pickled' % self)
|
||||
cls.__reduce_ex__ = _break_on_call_reduce
|
||||
|
@ -98,6 +101,7 @@ class _EnumDict(dict):
|
|||
enumeration member names.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
super(_EnumDict, self).__init__()
|
||||
self._member_names = []
|
||||
|
@ -155,7 +159,7 @@ class EnumMeta(type):
|
|||
# cannot be mixed with other types (int, float, etc.) if it has an
|
||||
# inherited __new__ unless a new __new__ is defined (or the resulting
|
||||
# class will fail).
|
||||
if type(classdict) is dict:
|
||||
if isinstance(classdict, dict):
|
||||
original_dict = classdict
|
||||
classdict = _EnumDict()
|
||||
for k, v in original_dict.items():
|
||||
|
@ -163,7 +167,7 @@ class EnumMeta(type):
|
|||
|
||||
member_type, first_enum = metacls._get_mixins_(bases)
|
||||
__new__, save_new, use_args = metacls._find_new_(classdict, member_type,
|
||||
first_enum)
|
||||
first_enum)
|
||||
# save enum items into separate mapping so they don't get baked into
|
||||
# the new class
|
||||
members = dict((k, classdict[k]) for k in classdict._member_names)
|
||||
|
@ -257,7 +261,6 @@ class EnumMeta(type):
|
|||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
# If a custom type is mixed into the Enum, and it does not know how
|
||||
# to pickle itself, pickle.dumps will succeed but pickle.loads will
|
||||
# fail. Rather than have the error show up later and possibly far
|
||||
|
@ -272,17 +275,16 @@ class EnumMeta(type):
|
|||
if '__reduce_ex__' not in classdict:
|
||||
if member_type is not object:
|
||||
methods = ('__getnewargs_ex__', '__getnewargs__',
|
||||
'__reduce_ex__', '__reduce__')
|
||||
'__reduce_ex__', '__reduce__')
|
||||
if not any(m in member_type.__dict__ for m in methods):
|
||||
_make_class_unpicklable(enum_class)
|
||||
unpicklable = True
|
||||
|
||||
|
||||
# double check that repr and friends are not the mixin's or various
|
||||
# things break (such as pickle)
|
||||
for name in ('__repr__', '__str__', '__format__', '__reduce_ex__'):
|
||||
class_method = getattr(enum_class, name)
|
||||
obj_method = getattr(member_type, name, None)
|
||||
getattr(member_type, name, None)
|
||||
enum_method = getattr(first_enum, name, None)
|
||||
if name not in classdict and class_method is not enum_method:
|
||||
if name == '__reduce_ex__' and unpicklable:
|
||||
|
@ -308,7 +310,7 @@ class EnumMeta(type):
|
|||
'__eq__',
|
||||
'__ne__',
|
||||
'__hash__',
|
||||
):
|
||||
):
|
||||
setattr(enum_class, method, getattr(int, method))
|
||||
|
||||
# replace any other __new__ with our own (as long as Enum is not None,
|
||||
|
@ -356,7 +358,7 @@ class EnumMeta(type):
|
|||
# (see issue19025).
|
||||
if attr in cls._member_map_:
|
||||
raise AttributeError(
|
||||
"%s: cannot delete Enum member." % cls.__name__)
|
||||
"%s: cannot delete Enum member." % cls.__name__)
|
||||
super(EnumMeta, cls).__delattr__(attr)
|
||||
|
||||
def __dir__(self):
|
||||
|
@ -450,7 +452,7 @@ class EnumMeta(type):
|
|||
if isinstance(names, basestring):
|
||||
names = names.replace(',', ' ').split()
|
||||
if isinstance(names, (tuple, list)) and isinstance(names[0], basestring):
|
||||
names = [(e, i+start) for (i, e) in enumerate(names)]
|
||||
names = [(e, i + start) for (i, e) in enumerate(names)]
|
||||
|
||||
# Here, names is either an iterable of (name, value) or a mapping.
|
||||
item = None # in case names is empty
|
||||
|
@ -491,20 +493,19 @@ class EnumMeta(type):
|
|||
if not bases or Enum is None:
|
||||
return object, Enum
|
||||
|
||||
|
||||
# double check that we are not subclassing a class with existing
|
||||
# enumeration members; while we're at it, see if any other data
|
||||
# type has been mixed in so we can use the correct __new__
|
||||
member_type = first_enum = None
|
||||
for base in bases:
|
||||
if (base is not Enum and
|
||||
if (base is not Enum and
|
||||
issubclass(base, Enum) and
|
||||
base._member_names_):
|
||||
raise TypeError("Cannot extend enumerations")
|
||||
# base is now the last base in bases
|
||||
if not issubclass(base, Enum):
|
||||
raise TypeError("new enumerations must be created as "
|
||||
"`ClassName([mixin_type,] enum_type)`")
|
||||
"`ClassName([mixin_type,] enum_type)`")
|
||||
|
||||
# get correct mix-in type (either mix-in type of Enum subclass, or
|
||||
# first base if last base is Enum)
|
||||
|
@ -562,7 +563,7 @@ class EnumMeta(type):
|
|||
N__new__,
|
||||
O__new__,
|
||||
E__new__,
|
||||
]:
|
||||
]:
|
||||
if method == '__member_new__':
|
||||
classdict['__new__'] = target
|
||||
return None, False, True
|
||||
|
@ -613,7 +614,7 @@ class EnumMeta(type):
|
|||
None.__new__,
|
||||
object.__new__,
|
||||
Enum.__new__,
|
||||
):
|
||||
):
|
||||
__new__ = target
|
||||
break
|
||||
if __new__ is not None:
|
||||
|
@ -641,14 +642,15 @@ class EnumMeta(type):
|
|||
temp_enum_dict = {}
|
||||
temp_enum_dict['__doc__'] = "Generic enumeration.\n\n Derive from this class to define new enumerations.\n\n"
|
||||
|
||||
|
||||
def __new__(cls, value):
|
||||
# all enum instances are actually created during class construction
|
||||
# without calling this method; this method is called by the metaclass'
|
||||
# __call__ (i.e. Color(3) ), and by pickle
|
||||
if type(value) is cls:
|
||||
if isinstance(value, cls):
|
||||
# For lookups like Color(Color.red)
|
||||
value = value.value
|
||||
#return value
|
||||
# return value
|
||||
# by-value search for a matching enum member
|
||||
# see if it's in the reverse mapping (for hashable values)
|
||||
try:
|
||||
|
@ -663,12 +665,14 @@ def __new__(cls, value):
|
|||
temp_enum_dict['__new__'] = __new__
|
||||
del __new__
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return "<%s.%s: %r>" % (
|
||||
self.__class__.__name__, self._name_, self._value_)
|
||||
self.__class__.__name__, self._name_, self._value_)
|
||||
temp_enum_dict['__repr__'] = __repr__
|
||||
del __repr__
|
||||
|
||||
|
||||
def __str__(self):
|
||||
return "%s.%s" % (self.__class__.__name__, self._name_)
|
||||
temp_enum_dict['__str__'] = __str__
|
||||
|
@ -677,15 +681,16 @@ del __str__
|
|||
if pyver >= 3.0:
|
||||
def __dir__(self):
|
||||
added_behavior = [
|
||||
m
|
||||
for cls in self.__class__.mro()
|
||||
for m in cls.__dict__
|
||||
if m[0] != '_' and m not in self._member_map_
|
||||
]
|
||||
m
|
||||
for cls in self.__class__.mro()
|
||||
for m in cls.__dict__
|
||||
if m[0] != '_' and m not in self._member_map_
|
||||
]
|
||||
return (['__class__', '__doc__', '__module__', ] + added_behavior)
|
||||
temp_enum_dict['__dir__'] = __dir__
|
||||
del __dir__
|
||||
|
||||
|
||||
def __format__(self, format_spec):
|
||||
# mixed-in Enums should use the mixed-in type's __format__, otherwise
|
||||
# we can get strange results with the Enum name showing up instead of
|
||||
|
@ -710,7 +715,7 @@ del __format__
|
|||
if pyver < 2.6:
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(other) is self.__class__:
|
||||
if isinstance(other, self.__class__):
|
||||
if self is other:
|
||||
return 0
|
||||
return -1
|
||||
|
@ -743,24 +748,27 @@ else:
|
|||
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(other) is self.__class__:
|
||||
if isinstance(other, self.__class__):
|
||||
return self is other
|
||||
return NotImplemented
|
||||
temp_enum_dict['__eq__'] = __eq__
|
||||
del __eq__
|
||||
|
||||
|
||||
def __ne__(self, other):
|
||||
if type(other) is self.__class__:
|
||||
if isinstance(other, self.__class__):
|
||||
return self is not other
|
||||
return NotImplemented
|
||||
temp_enum_dict['__ne__'] = __ne__
|
||||
del __ne__
|
||||
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self._name_)
|
||||
temp_enum_dict['__hash__'] = __hash__
|
||||
del __hash__
|
||||
|
||||
|
||||
def __reduce_ex__(self, proto):
|
||||
return self.__class__, (self._value_, )
|
||||
temp_enum_dict['__reduce_ex__'] = __reduce_ex__
|
||||
|
@ -773,18 +781,21 @@ del __reduce_ex__
|
|||
# members are not set directly on the enum class -- __getattr__ is
|
||||
# used to look them up.
|
||||
|
||||
|
||||
@_RouteClassAttributeToGetattr
|
||||
def name(self):
|
||||
return self._name_
|
||||
temp_enum_dict['name'] = name
|
||||
del name
|
||||
|
||||
|
||||
@_RouteClassAttributeToGetattr
|
||||
def value(self):
|
||||
return self._value_
|
||||
temp_enum_dict['value'] = value
|
||||
del value
|
||||
|
||||
|
||||
@classmethod
|
||||
def _convert(cls, name, module, filter, source=None):
|
||||
"""
|
||||
|
@ -815,12 +826,15 @@ del temp_enum_dict
|
|||
# Enum has now been created
|
||||
###########################
|
||||
|
||||
|
||||
class IntEnum(int, Enum):
|
||||
"""Enum where members are also (and must be) ints"""
|
||||
|
||||
|
||||
def _reduce_ex_by_name(self, proto):
|
||||
return self.name
|
||||
|
||||
|
||||
def unique(enumeration):
|
||||
"""Class decorator that ensures only unique members exist in an enumeration."""
|
||||
duplicates = []
|
||||
|
@ -829,9 +843,9 @@ def unique(enumeration):
|
|||
duplicates.append((name, member.name))
|
||||
if duplicates:
|
||||
duplicate_names = ', '.join(
|
||||
["%s -> %s" % (alias, name) for (alias, name) in duplicates]
|
||||
)
|
||||
["%s -> %s" % (alias, name) for (alias, name) in duplicates]
|
||||
)
|
||||
raise ValueError('duplicate names found in %r: %s' %
|
||||
(enumeration, duplicate_names)
|
||||
)
|
||||
return enumeration
|
||||
(enumeration, duplicate_names)
|
||||
)
|
||||
return enumeration
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from .get_graphql_type import get_graphql_type
|
||||
from .is_graphene_type import is_graphene_type
|
||||
from ..types.field import Field, InputField
|
||||
from ..types.unmountedtype import UnmountedType
|
||||
from .get_graphql_type import get_graphql_type
|
||||
from .is_graphene_type import is_graphene_type
|
||||
|
||||
|
||||
def get_fields_from_attrs(in_type, attrs):
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
from collections import OrderedDict
|
||||
from graphql import GraphQLField, GraphQLString, GraphQLInterfaceType, GraphQLInt, GraphQLFloat
|
||||
from ..get_fields import get_fields_from_attrs, get_fields_from_types
|
||||
|
||||
from ...types import Field, String, Argument, ObjectType
|
||||
from graphql import (GraphQLField, GraphQLFloat, GraphQLInt,
|
||||
GraphQLInterfaceType, GraphQLString)
|
||||
|
||||
from ...types import Argument, Field, ObjectType, String
|
||||
from ..get_fields import get_fields_from_attrs, get_fields_from_types
|
||||
|
||||
|
||||
def test_get_fields_from_attrs():
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import pytest
|
||||
|
||||
from graphql.type.definition import is_type
|
||||
from graphql import GraphQLObjectType, GraphQLField, GraphQLString
|
||||
|
||||
from graphene.types import ObjectType
|
||||
from ..get_graphql_type import get_graphql_type
|
||||
from graphql import GraphQLField, GraphQLObjectType, GraphQLString
|
||||
from graphql.type.definition import is_type
|
||||
|
||||
from ..get_graphql_type import get_graphql_type
|
||||
|
||||
MyGraphQLType = GraphQLObjectType('MyGraphQLType', fields={
|
||||
'field': GraphQLField(GraphQLString)
|
||||
|
@ -21,6 +20,7 @@ def test_get_graphql_type_graphene():
|
|||
|
||||
def test_get_graphql_type_custom_graphene_type():
|
||||
class MyGrapheneType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
graphql_type = MyGraphQLType
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from graphql import GraphQLObjectType, GraphQLField, GraphQLString
|
||||
from graphene.types import ObjectType
|
||||
from graphql import GraphQLField, GraphQLObjectType, GraphQLString
|
||||
|
||||
from ..is_graphene_type import is_graphene_type
|
||||
|
||||
from graphene.types import ObjectType
|
||||
|
||||
|
||||
def test_is_graphene_type_objecttype():
|
||||
class MyObjectType(ObjectType):
|
||||
|
|
Loading…
Reference in New Issue
Block a user