Skip to content

Commit 51b72d8

Browse files
committed
Renamed from JSON to Generic
As it's implementation is abstract of the serializer/unserializer used.
1 parent 2044d29 commit 51b72d8

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

graphene/types/jsontype.py renamed to graphene/types/generic.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from .scalars import Scalar
88

99

10-
class JSON(Scalar):
10+
class Generic(Scalar):
1111
"""
12-
The `JSON` scalar type represents JSON values as specified by
13-
[ECMA-404](http://www.ecma-international.org/
14-
publications/files/ECMA-ST/ECMA-404.pdf).
12+
The `Generic` scalar type represents a generic
13+
GraphQL scalar value that could be:
14+
String, Boolean, Int, Float, List or Object.
1515
"""
1616

1717
@staticmethod
@@ -32,8 +32,8 @@ def parse_literal(ast):
3232
elif isinstance(ast, FloatValue):
3333
return float(ast.value)
3434
elif isinstance(ast, ListValue):
35-
return [JSON.parse_literal(value) for value in ast.values]
35+
return [Generic.parse_literal(value) for value in ast.values]
3636
elif isinstance(ast, ObjectValue):
37-
return {field.name.value: JSON.parse_literal(field.value) for field in ast.fields}
37+
return {field.name.value: Generic.parse_literal(field.value) for field in ast.fields}
3838
else:
3939
return None

graphene/types/tests/test_jsontype.py renamed to graphene/types/tests/test_generic.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
from ..jsontype import JSON
1+
from ..generic import Generic
22
from ..objecttype import ObjectType
33
from ..schema import Schema
44

55

66
class Query(ObjectType):
7-
json = JSON(input=JSON())
7+
generic = Generic(input=Generic())
88

9-
def resolve_json(self, args, context, info):
9+
def resolve_generic(self, args, context, info):
1010
input = args.get('input')
1111
return input
1212

1313

1414
schema = Schema(query=Query)
1515

1616

17-
def test_json_query_variable():
18-
for json_value in [
17+
def test_generic_query_variable():
18+
for generic_value in [
1919
1,
2020
1.1,
2121
True,
@@ -45,20 +45,20 @@ def test_json_query_variable():
4545
None
4646
]:
4747
result = schema.execute(
48-
'''query Test($json: JSON){ json(input: $json) }''',
49-
variable_values={'json': json_value}
48+
'''query Test($generic: Generic){ generic(input: $generic) }''',
49+
variable_values={'generic': generic_value}
5050
)
5151
assert not result.errors
5252
assert result.data == {
53-
'json': json_value
53+
'generic': generic_value
5454
}
5555

5656

57-
def test_json_parse_literal_query():
57+
def test_generic_parse_literal_query():
5858
result = schema.execute(
5959
'''
6060
query {
61-
json(input: {
61+
generic(input: {
6262
int: 1,
6363
float: 1.1
6464
boolean: true,
@@ -78,7 +78,7 @@ def test_json_parse_literal_query():
7878
)
7979
assert not result.errors
8080
assert result.data == {
81-
'json': {
81+
'generic': {
8282
'int': 1,
8383
'float': 1.1,
8484
'boolean': True,

0 commit comments

Comments
 (0)