mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-27 00:09:45 +03:00
Merge b105731ada
into eb5108f81e
This commit is contained in:
commit
7a2f420d2a
|
@ -82,7 +82,7 @@ def test_generate_objecttype_with_fields():
|
|||
|
||||
def test_generate_objecttype_with_private_attributes():
|
||||
class MyObjectType(ObjectType):
|
||||
_private_state = None
|
||||
_private_state = Field(MyType)
|
||||
|
||||
assert '_private_state' not in MyObjectType._meta.fields
|
||||
assert hasattr(MyObjectType, '_private_state')
|
||||
|
|
|
@ -297,6 +297,27 @@ def test_query_middlewares():
|
|||
assert executed.data == {'hello': 'dlroW', 'other': 'rehto'}
|
||||
|
||||
|
||||
def test_query_private_values():
|
||||
class MyType(ObjectType):
|
||||
_private = String()
|
||||
public = String()
|
||||
|
||||
class Query(ObjectType):
|
||||
field = Field(MyType)
|
||||
|
||||
hello_schema = Schema(Query)
|
||||
|
||||
executed = hello_schema.execute('{ field { Private } }')
|
||||
assert executed.errors
|
||||
|
||||
executed = hello_schema.execute('{ field { _private } }')
|
||||
assert executed.errors
|
||||
|
||||
executed = hello_schema.execute('{ field { public } }')
|
||||
assert not executed.errors
|
||||
assert executed.data == {'field': None}
|
||||
|
||||
|
||||
def test_objecttype_on_instances():
|
||||
class Ship:
|
||||
|
||||
|
@ -442,8 +463,6 @@ def test_big_list_of_containers_multiple_fields_custom_resolvers_query_benchmark
|
|||
|
||||
|
||||
def test_query_annotated_resolvers():
|
||||
import json
|
||||
|
||||
context = Context(key="context")
|
||||
|
||||
class Query(ObjectType):
|
||||
|
|
|
@ -28,6 +28,8 @@ def yank_fields_from_attrs(attrs, _as=None, sort=True):
|
|||
'''
|
||||
fields_with_names = []
|
||||
for attname, value in list(attrs.items()):
|
||||
if attname.startswith('_'):
|
||||
continue
|
||||
field = get_field_as(value, _as)
|
||||
if not field:
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue
Block a user