Skip to main content

No project description provided

Project description

Ariadne Extensions

Set of scripts and helper utilities to extend Ariadne GraphQL library

Install

pip install -e git+https://github.com/aleszoulek/ariadne-extensions.git#egg=ariadne-extensions

Features

Federation support

Support for Federation Specification

Features

  1. Generate federation schema types and directives (_Any, _FieldSet, ...)
  2. Implements {_service{sdl}} query
  3. Detects boundary types and generates _Entities union
  4. Implements resolve reference helpers for boundary types queried over {_entities} query (resolve_reference and resolve_references decorators)
from os.path import dirname, join
from ariadne import QueryType, ObjectType, snake_case_fallback_resolvers

from ariadne_extensions import federation

query_type = QueryType()
manager = federation.FederatedManager(
    schema_sdl_file=join(dirname(__file__), 'schema.graphql'),
    query=query_type,
)

user_type = federation.FederatedObjectType('User')
photo_type = ObjectType('Photo')

@user_type.resolve_reference
def resolve_user_reference(reference):
    user_id = reference.get('id')
    return get_user_by_id(user_id)

@user_type.field('name')
def resolve_billing_account(obj, *_, id):
    return f'{obj.first_name} {obj_last_name}'

manager.add_types(user_type, photo_type)
manager.add_types(snake_case_fallback_resolvers)

schema = manager.get_schema()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ariadne-extensions-0.1.3.tar.gz (3.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page