Renamed Generic to GenericScalar

This commit is contained in:
Syrus Akbary 2017-02-20 22:22:54 -08:00
parent 8b0cd488d4
commit 11bed46a26
2 changed files with 7 additions and 7 deletions

View File

@ -7,9 +7,9 @@ from graphene.types.scalars import MIN_INT, MAX_INT
from .scalars import Scalar from .scalars import Scalar
class Generic(Scalar): class GenericScalar(Scalar):
""" """
The `Generic` scalar type represents a generic The `GenericScalar` scalar type represents a generic
GraphQL scalar value that could be: GraphQL scalar value that could be:
String, Boolean, Int, Float, List or Object. String, Boolean, Int, Float, List or Object.
""" """
@ -32,8 +32,8 @@ class Generic(Scalar):
elif isinstance(ast, FloatValue): elif isinstance(ast, FloatValue):
return float(ast.value) return float(ast.value)
elif isinstance(ast, ListValue): elif isinstance(ast, ListValue):
return [Generic.parse_literal(value) for value in ast.values] return [GenericScalar.parse_literal(value) for value in ast.values]
elif isinstance(ast, ObjectValue): elif isinstance(ast, ObjectValue):
return {field.name.value: Generic.parse_literal(field.value) for field in ast.fields} return {field.name.value: GenericScalar.parse_literal(field.value) for field in ast.fields}
else: else:
return None return None

View File

@ -1,10 +1,10 @@
from ..generic import Generic from ..generic import GenericScalar
from ..objecttype import ObjectType from ..objecttype import ObjectType
from ..schema import Schema from ..schema import Schema
class Query(ObjectType): class Query(ObjectType):
generic = Generic(input=Generic()) generic = GenericScalar(input=GenericScalar())
def resolve_generic(self, args, context, info): def resolve_generic(self, args, context, info):
input = args.get('input') input = args.get('input')
@ -45,7 +45,7 @@ def test_generic_query_variable():
None None
]: ]:
result = schema.execute( result = schema.execute(
'''query Test($generic: Generic){ generic(input: $generic) }''', '''query Test($generic: GenericScalar){ generic(input: $generic) }''',
variable_values={'generic': generic_value} variable_values={'generic': generic_value}
) )
assert not result.errors assert not result.errors