Skip to main content

This package extends the Ariadne library by adding a GraphQL HTTP handler designed for use in AWS Lambda environments.

Project description

Ariadne AWS Lambda Extension

This package extends the Ariadne library by adding a GraphQL HTTP handler designed for use in AWS Lambda environments. It enables easy integration of GraphQL services with AWS serverless infrastructure, making it straightforward to deploy GraphQL APIs without worrying about the underlying server management.

Introduction

This project provides an extension to the Ariadne GraphQL library, specifically tailored for deploying GraphQL APIs on AWS Lambda. It simplifies handling GraphQL requests by providing a custom HTTP handler that seamlessly integrates with the AWS Lambda and API Gateway, allowing developers to focus on their GraphQL schema and resolvers instead of server and infrastructure management.

Installation

To install the extension, use pip:

pip install ariadne-lambda

Quick Start

Here's a basic example of how to use the extension in your AWS Lambda function:

from typing import Any

from ariadne import QueryType, gql, make_executable_schema
from ariadne_lambda.graphql import GraphQLLambda
from asgiref.sync import async_to_sync
from aws_lambda_powertools.utilities.typing import LambdaContext

type_defs = gql(
    """
    type Query {
        hello: String!
    }
"""
)
query = QueryType()


@query.field("hello")
def resolve_hello(_, info):
    request = info.context["request"]
    user_agent = request.headers.get("user-agent", "guest")
    return "Hello, %s!" % user_agent


schema = make_executable_schema(type_defs, query)
graphql_app = GraphQLLambda(schema=schema)


def graphql_http_handler(event: dict[str, Any], context: LambdaContext):
    return async_to_sync(graphql_app)(event, context)

Documentation

For full documentation on Ariadne, visit Ariadne's Documentation. For details on AWS Lambda, refer to the AWS Lambda Developer Guide.

Features

  • Easy integration with AWS Lambda and API Gateway.
  • Support for GraphQL queries and mutations.
  • Customizable context and error handling.
  • Seamless extension of the Ariadne library for serverless applications.

Contributing

We welcome all contributions to Ariadne! If you've found a bug or issue, feel free to use GitHub issues. If you have any questions or feedback, don't hesitate to catch us on GitHub discussions.

For guidance and instructions, please see CONTRIBUTING.md.

Also make sure you follow @AriadneGraphQL on Twitter for latest updates, news and random musings!

Crafted with ❤️ by Mirumee Software ariadne@mirumee.com

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_lambda-0.4.1.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ariadne_lambda-0.4.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file ariadne_lambda-0.4.1.tar.gz.

File metadata

  • Download URL: ariadne_lambda-0.4.1.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ariadne_lambda-0.4.1.tar.gz
Algorithm Hash digest
SHA256 225ca650504bbbfb2fe9c956981174d4e43935dc754b78751a5fd73ce3664984
MD5 29bb0f4aa23a0d95d5a77cf872aa4324
BLAKE2b-256 d3ec58153205ab448d8a8872382ad7f8a106dd97056f52ad5e5eb6ea072acb99

See more details on using hashes here.

File details

Details for the file ariadne_lambda-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: ariadne_lambda-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ariadne_lambda-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0e187a237f41a9fea759f4735545b72cb8f453e2ea2798e7bc25761c51599713
MD5 eabbee516526b78d9ad51f43d67a5887
BLAKE2b-256 a89ef7acec44523babd8e66130fbb121ccdb8c647732be29d452f7167317c35a

See more details on using hashes here.

Supported by

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