mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-27 08:19:45 +03:00
Merge e11d595f51
into 8dff91d4c6
This commit is contained in:
commit
6a4b526373
|
@ -69,7 +69,7 @@ def test_edge():
|
||||||
assert edge_fields['node'].type == MyObject
|
assert edge_fields['node'].type == MyObject
|
||||||
|
|
||||||
assert isinstance(edge_fields['other'], Field)
|
assert isinstance(edge_fields['other'], Field)
|
||||||
assert edge_fields['other'].type == String
|
assert edge_fields['other'].type.__class__ == String
|
||||||
|
|
||||||
|
|
||||||
def test_edge_with_bases():
|
def test_edge_with_bases():
|
||||||
|
@ -93,7 +93,7 @@ def test_edge_with_bases():
|
||||||
assert edge_fields['node'].type == MyObject
|
assert edge_fields['node'].type == MyObject
|
||||||
|
|
||||||
assert isinstance(edge_fields['other'], Field)
|
assert isinstance(edge_fields['other'], Field)
|
||||||
assert edge_fields['other'].type == String
|
assert edge_fields['other'].type.__class__ == String
|
||||||
|
|
||||||
|
|
||||||
def test_edge_on_node():
|
def test_edge_on_node():
|
||||||
|
|
|
@ -81,7 +81,7 @@ def test_mutation():
|
||||||
assert field.args['input'].type.of_type == SaySomething.Input
|
assert field.args['input'].type.of_type == SaySomething.Input
|
||||||
assert isinstance(fields['client_mutation_id'], Field)
|
assert isinstance(fields['client_mutation_id'], Field)
|
||||||
assert fields['client_mutation_id'].name == 'clientMutationId'
|
assert fields['client_mutation_id'].name == 'clientMutationId'
|
||||||
assert fields['client_mutation_id'].type == String
|
assert fields['client_mutation_id'].type.__class__ == String
|
||||||
|
|
||||||
|
|
||||||
def test_mutation_input():
|
def test_mutation_input():
|
||||||
|
@ -90,9 +90,9 @@ def test_mutation_input():
|
||||||
fields = Input._meta.fields
|
fields = Input._meta.fields
|
||||||
assert list(fields.keys()) == ['what', 'client_mutation_id']
|
assert list(fields.keys()) == ['what', 'client_mutation_id']
|
||||||
assert isinstance(fields['what'], InputField)
|
assert isinstance(fields['what'], InputField)
|
||||||
assert fields['what'].type == String
|
assert fields['what'].type.__class__ == String
|
||||||
assert isinstance(fields['client_mutation_id'], InputField)
|
assert isinstance(fields['client_mutation_id'], InputField)
|
||||||
assert fields['client_mutation_id'].type == String
|
assert fields['client_mutation_id'].type.__class__ == String
|
||||||
|
|
||||||
|
|
||||||
def test_subclassed_mutation():
|
def test_subclassed_mutation():
|
||||||
|
@ -113,11 +113,11 @@ def test_subclassed_mutation_input():
|
||||||
fields = Input._meta.fields
|
fields = Input._meta.fields
|
||||||
assert list(fields.keys()) == ['shared', 'additional_field', 'client_mutation_id']
|
assert list(fields.keys()) == ['shared', 'additional_field', 'client_mutation_id']
|
||||||
assert isinstance(fields['shared'], InputField)
|
assert isinstance(fields['shared'], InputField)
|
||||||
assert fields['shared'].type == String
|
assert fields['shared'].type.__class__ == String
|
||||||
assert isinstance(fields['additional_field'], InputField)
|
assert isinstance(fields['additional_field'], InputField)
|
||||||
assert fields['additional_field'].type == String
|
assert fields['additional_field'].type.__class__ == String
|
||||||
assert isinstance(fields['client_mutation_id'], InputField)
|
assert isinstance(fields['client_mutation_id'], InputField)
|
||||||
assert fields['client_mutation_id'].type == String
|
assert fields['client_mutation_id'].type.__class__ == String
|
||||||
|
|
||||||
|
|
||||||
# def test_node_query():
|
# def test_node_query():
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import six
|
import six
|
||||||
|
import types
|
||||||
|
|
||||||
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
|
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
|
||||||
StringValue)
|
StringValue)
|
||||||
|
@ -37,6 +38,13 @@ class Scalar(six.with_metaclass(ScalarTypeMeta, UnmountedType)):
|
||||||
used to parse input from ast or variables and to ensure validity.
|
used to parse input from ast or variables and to ensure validity.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(Scalar, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def get_type(self):
|
||||||
|
return self
|
||||||
|
self.get_type = types.MethodType(get_type, self)
|
||||||
|
|
||||||
serialize = None
|
serialize = None
|
||||||
parse_value = None
|
parse_value = None
|
||||||
parse_literal = None
|
parse_literal = None
|
||||||
|
|
|
@ -83,7 +83,7 @@ def test_defines_a_query_only_schema():
|
||||||
assert issubclass(article_field_type, ObjectType)
|
assert issubclass(article_field_type, ObjectType)
|
||||||
|
|
||||||
title_field = article_field_type._meta.fields['title']
|
title_field = article_field_type._meta.fields['title']
|
||||||
assert title_field.type == String
|
assert title_field.type.__class__ == String
|
||||||
|
|
||||||
author_field = article_field_type._meta.fields['author']
|
author_field = article_field_type._meta.fields['author']
|
||||||
author_field_type = author_field.type
|
author_field_type = author_field.type
|
||||||
|
|
|
@ -28,7 +28,7 @@ from .utils import get_field_as
|
||||||
|
|
||||||
|
|
||||||
def is_graphene_type(_type):
|
def is_graphene_type(_type):
|
||||||
if isinstance(_type, (List, NonNull)):
|
if isinstance(_type, (List, NonNull, Scalar)):
|
||||||
return True
|
return True
|
||||||
if inspect.isclass(_type) and issubclass(_type, (ObjectType, InputObjectType, Scalar, Interface, Union, Enum)):
|
if inspect.isclass(_type) and issubclass(_type, (ObjectType, InputObjectType, Scalar, Interface, Union, Enum)):
|
||||||
return True
|
return True
|
||||||
|
@ -72,6 +72,8 @@ class TypeMap(GraphQLTypeMap):
|
||||||
if isinstance(_type, GrapheneGraphQLType):
|
if isinstance(_type, GrapheneGraphQLType):
|
||||||
assert _type.graphene_type == type
|
assert _type.graphene_type == type
|
||||||
return map
|
return map
|
||||||
|
if isinstance(type, Scalar):
|
||||||
|
return self.construct_scalar(map, type.__class__)
|
||||||
if issubclass(type, ObjectType):
|
if issubclass(type, ObjectType):
|
||||||
return self.construct_objecttype(map, type)
|
return self.construct_objecttype(map, type)
|
||||||
if issubclass(type, InputObjectType):
|
if issubclass(type, InputObjectType):
|
||||||
|
|
|
@ -55,7 +55,8 @@ class UnmountedType(OrderedType):
|
||||||
return (
|
return (
|
||||||
self is other or (
|
self is other or (
|
||||||
isinstance(other, UnmountedType) and
|
isinstance(other, UnmountedType) and
|
||||||
self.get_type() == other.get_type() and
|
self.get_type()._meta == other.get_type()._meta and
|
||||||
|
# self.get_type()._meta.name == other.get_type()._meta.name and
|
||||||
self.args == other.args and
|
self.args == other.args and
|
||||||
self.kwargs == other.kwargs
|
self.kwargs == other.kwargs
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user