diff --git a/graphene_directives/schema.py b/graphene_directives/schema.py index b1ee75b..b1f3cb7 100644 --- a/graphene_directives/schema.py +++ b/graphene_directives/schema.py @@ -5,7 +5,7 @@ from graphene import Schema as GrapheneSchema from graphene.types.scalars import ScalarOptions from graphene.types.union import UnionOptions -from graphene.utils.str_converters import to_camel_case +from graphene.utils.str_converters import to_camel_case, to_snake_case from graphql import ( DirectiveLocation, GraphQLArgument, @@ -453,11 +453,9 @@ def get_directive_applied_field_types(self) -> set: for field in fields: field_type = ( - getattr( - entity_type.graphene_type, - self.type_attribute_to_field_name(field), - None, - ) + # auto-camelcasing can cause problems + getattr(entity_type.graphene_type, to_camel_case(field), None) + or getattr(entity_type.graphene_type, to_snake_case(field), None) if not is_enum_type(entity_type) else field.value ) diff --git a/pyproject.toml b/pyproject.toml index cad800a..b04f246 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "graphene-directives" -version = "0.4.2" +version = "0.4.3" packages = [{include = "graphene_directives"}] description = "Schema Directives implementation for graphene" authors = ["Strollby "] diff --git a/tests/schema_files/test_directive.graphql b/tests/schema_files/test_directive.graphql index 162e71d..a246adc 100644 --- a/tests/schema_files/test_directive.graphql +++ b/tests/schema_files/test_directive.graphql @@ -81,6 +81,7 @@ scalar DateNewScalar @cache(maxAge: 500) @authenticated(required: true) type User @authenticated(required: true) { name: String password: String + camelCased: String @hidden price(currency: Int @hidden, country: Int @authenticated(required: true) @hidden): String } diff --git a/tests/test_directive.py b/tests/test_directive.py index 1e5a0de..087aa1b 100644 --- a/tests/test_directive.py +++ b/tests/test_directive.py @@ -237,6 +237,7 @@ class Admin(graphene.ObjectType): class User(graphene.ObjectType): name = graphene.String() password = graphene.String() + camel_cased = directive(HiddenDirective, field=graphene.String()) price = graphene.Field( graphene.String, currency=directive(