File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
graphene_django/rest_framework Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,9 @@ def fields_for_serializer(
3939 field .read_only
4040 and is_input
4141 and lookup_field != name , # don't show read_only fields in Input
42+ isinstance (
43+ field , serializers .HiddenField
44+ ), # don't show hidden fields in Input
4245 ]
4346 )
4447
Original file line number Diff line number Diff line change @@ -164,6 +164,21 @@ class Meta:
164164 ), "'cool_name' is read_only field and shouldn't be on arguments"
165165
166166
167+ def test_hidden_fields ():
168+ class SerializerWithHiddenField (serializers .Serializer ):
169+ cool_name = serializers .CharField ()
170+ user = serializers .HiddenField (default = serializers .CurrentUserDefault ())
171+
172+ class MyMutation (SerializerMutation ):
173+ class Meta :
174+ serializer_class = SerializerWithHiddenField
175+
176+ assert "cool_name" in MyMutation .Input ._meta .fields
177+ assert (
178+ "user" not in MyMutation .Input ._meta .fields
179+ ), "'user' is hidden field and shouldn't be on arguments"
180+
181+
167182def test_nested_model ():
168183 class MyFakeModelGrapheneType (DjangoObjectType ):
169184 class Meta :
You can’t perform that action at this time.
0 commit comments