graphql-utils
raw JSON → 0.4 verified Fri May 01 auth: no python
A small utility library for common tasks when interacting with GraphQL APIs, such as converting between CamelCase and snake_case field names. Version 0.4 is the latest. Release cadence is low.
pip install graphql-utils Common errors
error ModuleNotFoundError: No module named 'graphql.utils' ↓
cause Incorrect import path; using dot instead of underscore.
fix
Use 'from graphql_utils import CamelCase' (note underscore).
error ModuleNotFoundError: No module named 'graphql_utils' ↓
cause Library not installed or environment issue.
fix
Run 'pip install graphql-utils'.
Warnings
gotcha The correct import is from graphql_utils (with underscore), not graphql.utils. Many users mistakenly import from the wrong module. ↓
fix Use 'from graphql_utils import CamelCase' instead of 'from graphql.utils import CamelCase'.
gotcha The method names are confusing: CamelCase class has snake_case_to_camel method, not camel_to_snake_case. Check the class's method names carefully. ↓
fix Use CamelCase().snake_case_to_camel() to convert snake_case to camelCase; for reverse, use CamelCase().camel_to_snake_case().
deprecated Version 0.4 is likely stable but there are no recent releases. The library may be in maintenance mode. ↓
fix Check the GitHub repo for updates or consider alternatives if you need active maintenance.
Imports
- CamelCase wrong
from graphql.utils import CamelCasecorrectfrom graphql_utils import CamelCase - snake_case_to_camel
from graphql_utils import snake_case_to_camel - camel_to_snake_case
from graphql_utils import camel_to_snake_case
Quickstart
from graphql_utils import CamelCase
# Convert GraphQL response fields from camelCase to snake_case
data = {"userName": "John", "lastName": "Doe"}
converter = CamelCase()
snake_data = converter.snake_case_to_camel(data)
print(snake_data)
# Output: {"user_name": "John", "last_name": "Doe"}