Flaxon 0.3.0 and Teloce-Py 0.3.0 are available on PyPI. Release instructions are maintained on this site; source links identify the framework snapshot. Check version and upgrade guidance.
GraphQL API Reference
Schema
GraphQLSchema(self, query: ObjectType | None=None, mutation: ObjectType | None=None, subscription: ObjectType | None=None)Graph qlschema implementation for the graphql subsystem.
Public methods and properties
add_type
def add_type(self, type_obj: ObjectType) -> NoneAdd the type.
get_type
def get_type(self, name: str) -> ObjectType | NoneReturn the type.
get_types
def get_types(self) -> dict[str, ObjectType]Return the types.
add_directive
def add_directive(self, directive: Directive) -> NoneAdd the directive.
get_directives
def get_directives(self) -> list[Directive]Return the directives.
resolver
def resolver(self) -> ResolverPerform the resolver operation for graph qlschema.
execute
async def execute(self, query: str, variables: dict[str, Any] | None=None, context: Any=None, operation_name: str | None=None) -> dict[str, Any]Execute the supplied operation with its parameters.
introspection
async def introspection(self) -> dict[str, Any]Perform the introspection operation for graph qlschema.
Types
ObjectType
ObjectType(self, name: str, fields: dict[str, Field], description: str | None=None)Object type implementation for the graphql subsystem.
Public methods and properties
add_interface
def add_interface(self, interface: InterfaceType) -> NoneAdd the interface.
InterfaceType
InterfaceType(self, name: str, fields: dict[str, Field], description: str | None=None)Interface type implementation for the graphql subsystem.
UnionType
UnionType(self, name: str, types: list[ObjectType], description: str | None=None)Union type implementation for the graphql subsystem.
InputObjectType
InputObjectType(self, name: str, fields: dict[str, InputField], description: str | None=None)Input object type implementation for the graphql subsystem.
Field
Field(self, type_: Any, args: dict[str, Any] | None=None, resolver: Any=None)Validate and convert field values.
Public methods and properties
resolve
def resolve(self, parent: Any, args: dict[str, Any], context: Any, info: Any) -> AnyPerform the resolve operation for field.
InputField
InputField(self, type_: Any, default_value: Any=None)Validate and convert input field values.
GraphQL List Type
NonNull
Scalar
Scalar(self, name: str, description: str | None=None)Scalar implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> AnyConvert the supplied value into its serialized representation.
parse_value
def parse_value(self, value: Any) -> AnyParse the value.
parse_literal
def parse_literal(self, value: Any) -> AnyParse the literal.
set_serialize
def set_serialize(self, func: Any) -> NoneSet the serialize.
set_parse_value
def set_parse_value(self, func: Any) -> NoneSet the parse value.
set_parse_literal
def set_parse_literal(self, func: Any) -> NoneSet the parse literal.
Scalars
ID(self)Id implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> strConvert the supplied value into its serialized representation.
DateTime(self)Date time implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> strConvert the supplied value into its serialized representation.
parse_value
def parse_value(self, value: Any) -> datetime.datetimeParse the value.
Decimal(self)Decimal implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> strConvert the supplied value into its serialized representation.
parse_value
def parse_value(self, value: Any) -> decimal.DecimalParse the value.
JSON(self)Json implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> AnyConvert the supplied value into its serialized representation.
parse_value
def parse_value(self, value: Any) -> AnyParse the value.
parse_literal
def parse_literal(self, value: Any) -> AnyParse the literal.
UUID(self)Uuid implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> strConvert the supplied value into its serialized representation.
parse_value
def parse_value(self, value: Any) -> AnyParse the value.
URL(self)Url implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> strConvert the supplied value into its serialized representation.
Email(self)Email implementation for the graphql subsystem.
Public methods and properties
serialize
def serialize(self, value: Any) -> strConvert the supplied value into its serialized representation.
Resolver
Resolver(self)Resolver implementation for the graphql subsystem.
Public methods and properties
register
def register(self, type_name: str, field_name: str, resolver: Any) -> NonePerform the register operation for resolver.
register_type_resolver
def register_type_resolver(self, type_name: str, resolver: Any) -> NoneRegister the type resolver.
get
def get(self, type_name: str, field_name: str) -> AnyRetrieve the requested value using this object's configured behavior.
get_type_resolver
def get_type_resolver(self, type_name: str) -> AnyReturn the type resolver.
resolve
async def resolve(self, type_name: str, field_name: str, parent: Any, args: dict[str, Any], context: Any, info: Any) -> AnyPerform the resolve operation for resolver.
Directives
Directive
Directive(self, name: str, description: str | None=None, locations: list[str] | None=None, args: dict[str, Any] | None=None)Directive implementation for the graphql subsystem.
Public methods and properties
apply
def apply(self, context: Any, args: dict[str, Any]) -> boolPerform the apply operation for directive.
Built-in Directives
SkipDirective(self)Skip directive implementation for the graphql subsystem.
Public methods and properties
apply
def apply(self, context: Any, args: dict[str, Any]) -> boolPerform the apply operation for skip directive.
IncludeDirective(self)Include directive implementation for the graphql subsystem.
Public methods and properties
apply
def apply(self, context: Any, args: dict[str, Any]) -> boolPerform the apply operation for include directive.
DeprecatedDirective(self)Deprecated directive implementation for the graphql subsystem.
Decorators
def graphql_type(name: str, description: str | None=None)Provide type behavior for GraphQL integration.
def graphql_field(description: str | None=None)Provide field behavior for GraphQL integration.
def graphql_query(name: str | None=None, description: str | None=None)Provide query behavior for GraphQL integration.
def graphql_mutation(name: str | None=None, description: str | None=None)Provide mutation behavior for GraphQL integration.
def graphql_subscription(name: str | None=None, description: str | None=None)Provide subscription behavior for GraphQL integration.
Subscriptions
SubscriptionManager
SubscriptionManager(self, backend: Any=None)Subscription manager implementation for the graphql subsystem.
Public methods and properties
subscribe
async def subscribe(self, operation_id: str, context: Any, variables: dict[str, Any]) -> strRegister a subscription for the supplied event or operation.
unsubscribe
async def unsubscribe(self, subscription_id: str) -> NoneRemove the requested subscription.
publish
async def publish(self, operation_id: str, data: Any) -> NonePerform the publish operation for subscription manager.
next
async def next(self, subscription_id: str) -> AnyPerform the next operation for subscription manager.
get_subscription_count
def get_subscription_count(self) -> intReturn the subscription count.
get_subscriptions_by_operation
def get_subscriptions_by_operation(self, operation_id: str) -> list[str]Return the subscriptions by operation.
MemorySubscriptionBackend
MemorySubscriptionBackend(self)In-process subscription backend, matching RedisSubscriptionBackend's interface.
Suitable for single-process deployments or local development. For multi-process or multi-server deployments, use RedisSubscriptionBackend instead so publishes from one process reach subscribers connected to another.
Public methods and properties
connect
async def connect(self) -> NoneNo-op: nothing to connect to for the in-memory backend.
disconnect
async def disconnect(self) -> NoneRelease any pending queues.
subscribe
async def subscribe(self, operation_id: str, context: Any, variables: dict[str, Any]) -> strRegister a subscription for the supplied event or operation.
unsubscribe
async def unsubscribe(self, subscription_id: str) -> NoneRemove the requested subscription.
publish
async def publish(self, operation_id: str, data: Any) -> NonePerform the publish operation for memory subscription backend.
next
async def next(self, subscription_id: str) -> AnyPerform the next operation for memory subscription backend.
RedisSubscriptionBackend
RedisSubscriptionBackend(self, redis_url: str='redis://localhost:6379/0', prefix: str='graphql:subscription')Provide redis subscription storage for graphql operations.
Public methods and properties
connect
async def connect(self) -> NoneOpen the configured connection.
disconnect
async def disconnect(self) -> NoneClose the configured connection.
subscribe
async def subscribe(self, operation_id: str, context: Any, variables: dict[str, Any]) -> strRegister a subscription for the supplied event or operation.
unsubscribe
async def unsubscribe(self, subscription_id: str) -> NoneRemove the requested subscription.
publish
async def publish(self, operation_id: str, data: Any) -> NonePerform the publish operation for redis subscription backend.
next
async def next(self, subscription_id: str) -> AnyPerform the next operation for redis subscription backend.
Middleware
GraphQLMiddleware(self, app: Any)Graph qlmiddleware implementation for the graphql subsystem.
Public methods and properties
add
def add(self, middleware: Any) -> NoneAdd the supplied item to this collection.
Extensions
ComplexityExtension
ComplexityExtension(self, max_complexity: int=100, enabled: bool=True)Complexity extension implementation for the graphql subsystem.
Public methods and properties
set_cost
def set_cost(self, field_name: str, cost: int) -> NoneSet the cost.
set_costs
def set_costs(self, costs: dict[str, int]) -> NoneSet the costs.
get_cost
def get_cost(self, field_name: str) -> intReturn the cost.
calculate_complexity
def calculate_complexity(self, document: Any) -> intPerform the calculate complexity operation for complexity extension.
validate_complexity
def validate_complexity(self, document: Any) -> boolValidate the complexity.
before
async def before(self, context: dict[str, Any]) -> NonePerform the before operation for complexity extension.
after
async def after(self, context: dict[str, Any], result: dict[str, Any]) -> NonePerform the after operation for complexity extension.
DepthLimitExtension
DepthLimitExtension(self, max_depth: int=10, enabled: bool=True)Depth limit extension implementation for the graphql subsystem.
Public methods and properties
calculate_depth
def calculate_depth(self, document: Any) -> intPerform the calculate depth operation for depth limit extension.
validate_depth
def validate_depth(self, document: Any) -> boolValidate the depth.
before
async def before(self, context: dict[str, Any]) -> NonePerform the before operation for depth limit extension.
after
async def after(self, context: dict[str, Any], result: dict[str, Any]) -> NonePerform the after operation for depth limit extension.
PersistedQueriesExtension
PersistedQueriesExtension(self, storage: dict[str, str] | None=None, enabled: bool=True)Persisted queries extension implementation for the graphql subsystem.
Public methods and properties
register
def register(self, query_hash: str, query: str) -> NonePerform the register operation for persisted queries extension.
register_many
def register_many(self, queries: dict[str, str]) -> NoneRegister the many.
get
def get(self, query_hash: str) -> str | NoneRetrieve the requested value using this object's configured behavior.
get_auto_hash
def get_auto_hash(self, query: str) -> strReturn the auto hash.
resolve_persisted_query
def resolve_persisted_query(self, query_hash: str, query_text: str | None=None) -> str | NoneResolve the persisted query.
save_persisted_query
def save_persisted_query(self, query_text: str) -> strSave the persisted query.
load_persisted_queries
def load_persisted_queries(self, file_path: str) -> NoneLoad the persisted queries.
save_persisted_queries
def save_persisted_queries(self, file_path: str) -> NoneSave the persisted queries.
before
async def before(self, context: dict[str, Any]) -> NonePerform the before operation for persisted queries extension.
after
async def after(self, context: dict[str, Any], result: dict[str, Any]) -> NonePerform the after operation for persisted queries extension.
Playgrounds
GraphiQL
GraphiQLPlayground(self, endpoint: str='/graphql')Public methods and properties
render
async def render(self, request: Request) -> HTMLResponseAltair
AltairPlayground(self, endpoint: str='/graphql')Public methods and properties
render
async def render(self, request: Request) -> HTMLResponseUtilities
async def graphql(schema: Any, query: str, variables: dict[str, Any] | None=None, context: Any=None, operation_name: str | None=None) -> dict[str, Any]Execute a GraphQL query against a schema. Shorthand for schema.execute(...).
def graphql_to_dict(obj: Any) -> dict[str, Any]Provide to dict behavior for GraphQL integration.
def graphql_to_json(obj: Any) -> strProvide to json behavior for GraphQL integration.
def graphql_format_error(message: str, line: int | None=None, column: int | None=None) -> dict[str, Any]Provide format error behavior for GraphQL integration.
def graphql_is_valid_name(name: str) -> boolProvide is valid name behavior for GraphQL integration.
def graphql_sanitize_name(name: str) -> strProvide sanitize name behavior for GraphQL integration.
Exceptions
GraphQLError
GraphQLError(self, message: str, locations: list[dict[str, int]] | None=None, path: list[str | int] | None=None)Report a graph qlerror failure.
Public methods and properties
to_dict
def to_dict(self) -> dict[str, Any]Return a dictionary representation of the current value.
GraphQL Exceptions
GraphQLSyntaxError(self, message: str, line: int, column: int)Report a graph qlsyntax failure.
AST
Document(self, definitions: list[Any])Document implementation for the graphql subsystem.
OperationDefinition(self, operation: str, name: Any=None, variable_definitions: list[Any] | None=None, directives: list[Any] | None=None, selection_set: Any=None)Operation definition implementation for the graphql subsystem.
SelectionSet(self, selections: list[Any])Selection set implementation for the graphql subsystem.
Field(self, name: Any, alias: Any=None, arguments: list[Any] | None=None, directives: list[Any] | None=None, selection_set: Any=None)Validate and convert field values.
FragmentSpread(self, name: Any, directives: list[Any] | None=None)Fragment spread implementation for the graphql subsystem.
InlineFragment(self, type_condition: Any=None, directives: list[Any] | None=None, selection_set: Any=None)Inline fragment implementation for the graphql subsystem.
FragmentDefinition(self, name: Any, type_condition: Any, directives: list[Any] | None=None, selection_set: Any=None)Fragment definition implementation for the graphql subsystem.
VariableDefinition(self, name: Any, type: Any, default_value: Any=None)Variable definition implementation for the graphql subsystem.
Argument(self, name: Any, value: Any)Argument implementation for the graphql subsystem.
Directive(self, name: Any, arguments: list[Any] | None=None)Directive implementation for the graphql subsystem.
NonNullType(self, type: Any)Non null type implementation for the graphql subsystem.
FloatValue(self, value: str)Float value implementation for the graphql subsystem.
StringValue(self, value: str)String value implementation for the graphql subsystem.
BooleanValue(self, value: bool)Boolean value implementation for the graphql subsystem.
ListValue(self, values: list[Any])List value implementation for the graphql subsystem.
ObjectValue(self, fields: list[Any])Object value implementation for the graphql subsystem.
ObjectField(self, name: Any, value: Any)Validate and convert object field values.
Use this capability in a full-stack app
Flaxon serves Python APIs and Teloce interfaces in one project. Keep validation, authorization and privileged operations on the server; components call those endpoints and present their results. Follow the full-stack lessons and Teloce integration reference to connect this capability to pages, components and application modules.