Skip to content

Commit

Permalink
fix: camel casing caused missing field decorators
Browse files Browse the repository at this point in the history
  • Loading branch information
mak626 committed Jan 13, 2024
1 parent c9f8491 commit eda40c6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions graphene_directives/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Expand Down
1 change: 1 addition & 0 deletions tests/schema_files/test_directive.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions tests/test_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit eda40c6

Please sign in to comment.