Big News: Socket Selected for OpenAI's Cybersecurity Grant Program.Details
Socket
Book a DemoSign in
Socket

graphql-http

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-http

HTTP Server for GraphQL.

pipPyPI
Version
2.1.5
Maintainers
1

GraphQL HTTP

PyPI version Python versions License: MIT

📚 Documentation | 📦 PyPI | 🔧 GitHub

A lightweight, production-ready HTTP server for GraphQL APIs built on top of Starlette/FastAPI. This server provides a simple yet powerful way to serve GraphQL schemas over HTTP with built-in support for authentication, CORS, GraphiQL integration, and more.

Features

  • 🚀 High Performance: Built on Starlette/ASGI for excellent async performance
  • 🔐 JWT Authentication: Built-in JWT authentication with JWKS support
  • 🌐 CORS Support: Configurable CORS middleware for cross-origin requests
  • 🎨 GraphiQL Integration: Interactive GraphQL IDE for development
  • 📊 Health Checks: Built-in health check endpoints
  • 🔄 Batch Queries: Support for batched GraphQL operations

Installation

uv add graphql_http

Or with pip:

pip install graphql_http

Quick Start

Basic Usage

from graphql import GraphQLSchema, GraphQLObjectType, GraphQLField, GraphQLString
from graphql_http import GraphQLHTTP

# Define your GraphQL schema
schema = GraphQLSchema(
    query=GraphQLObjectType(
        name="Query",
        fields={
            "hello": GraphQLField(
                GraphQLString,
                resolve=lambda obj, info: "Hello, World!"
            )
        }
    )
)

# Create the HTTP server
app = GraphQLHTTP(schema=schema)

# Run the server
if __name__ == "__main__":
    app.run(host="0.0.0.0", port=8000)

Using with graphql-api

For building GraphQL schemas, use graphql-api:

from graphql_api import GraphQLAPI
from graphql_http import GraphQLHTTP

api = GraphQLAPI()

@api.type(is_root_type=True)
class Query:
    @api.field
    def hello(self, name: str = "World") -> str:
        return f"Hello, {name}!"

server = GraphQLHTTP.from_api(api)
server.run()

See the documentation for configuration, authentication, and advanced features.

Documentation

Visit the official documentation for comprehensive guides, examples, and API reference.

Key Topics

License

MIT License - see LICENSE file for details.

Keywords

GraphQL

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts