Ariadne 0.19
Ariadne 0.19 is now out!
Ariadne 0.19 is a feature release that brings improvements for GraphQL inputs and enums. It also includes improvements to the Apollo Federation implementation contributed by the community.
Input handling improvements
Ariadne now provides an InputType
class which can be used to setup custom Python representation of GraphQL input types and mappings between input's fields and original Python directory with values:
# Store input field's values under custom dict keys
InputType(
"InputName",
out_names={
"isClosed": "is_closed",
"isActive": "requires_activation",
},
)
@dataclass
class UserInput:
name: str
email: str
requires_activation: Optional[bool] = None
InputType(
"UserInput",
# Logic for converting input's data to Python repr is customizable
lambda data: UserInput(**data),
{"isActive": "requires_activation"},
)
Enum handling improvements
Ariadne already provides an EnumType
class which can be used to assign custom Python values to GraphQL enums:
class TaskPriority(enum.IntEnum):
VERY_LOW = 0
LOW = 1
STANDARD = 2
HIGH = 3
URGENT = 4
EnumType("TaskPriority", TaskPriority)
make_executable_schema
now accepts Enum
s directly and attempts to associate them with their GraphQL counterparts on their name. In above case if there's already an enum in GraphQL schema named TaskPriority
, TaskPriority
can be passed to schema directly.
EnumType
still remains useful in situations when enum's names are different between Python and GraphQL schema, and when enum's Python values are set using dict
.
Federation improvements
Our community has contributed few improvements to Ariadne's contrib.federation
package, providing utilities for writing Apollo Federation subgraphs.
Thanks to Alexis Rhote's contributions, make_federated_schema
now supports convert_names_case
just like how make_executable_schema
does.
Dan Lepadatu has contributed a support for @interfaceObject
directive.
Dan Ring has contributed an improvements to Ariadne's federated schema processing logic, making it more tight and less error prone.
We would also like to give a shout out to Dariusz Kuc for keeping an eye on Ariadne's Federation support, and to Patrick Arminio for contributing template for federalable Ariadne Fast API service.
CHANGELOG
- Added
InputType
for setting Python representations of GraphQL Input types - Added support for passing
Enum
types directly tomake_executable_schema
- Added
convert_names_case
option tomake_federated_schema
. - Added support for the
@interfaceObject
directive in Apollo Federation. - Fixed federation support for directives without surrounding whitespace.