MyGit

strawberry-graphql/strawberry

Fork: 627 Star: 4640 (更新于 2026-04-09 03:25:11)

license: MIT

Language: Python .

A GraphQL library for Python that leverages type annotations 🍓

最后发布版本: 0.314.3 ( 2026-04-09 02:04:52)

官方网址 GitHub网址

Strawberry GraphQL

Python GraphQL library based on dataclasses

Discord PyPI

Installation ( Quick Start )

The quick start method provides a server and CLI to get going quickly. Install with:

pip install "strawberry-graphql[cli]"

Getting Started

Create a file called app.py with the following code:

import strawberry


@strawberry.type
class User:
    name: str
    age: int


@strawberry.type
class Query:
    @strawberry.field
    def user(self) -> User:
        return User(name="Patrick", age=100)


schema = strawberry.Schema(query=Query)

This will create a GraphQL schema defining a User type and a single query field user that will return a hardcoded user.

To serve the schema using the dev server run the following command:

strawberry dev app

Open the dev server by clicking on the following link: http://0.0.0.0:8000/graphql

This will open GraphiQL where you can test the API.

Type-checking

Strawberry comes with a mypy plugin that enables statically type-checking your GraphQL schema. To enable it, add the following lines to your mypy.ini configuration:

[mypy]
plugins = strawberry.ext.mypy_plugin

Django Integration

A Django view is provided for adding a GraphQL endpoint to your application.

  1. Add the app to your INSTALLED_APPS.
INSTALLED_APPS = [
    ...,  # your other apps
    "strawberry.django",
]
  1. Add the view to your urls.py file.
from strawberry.django.views import GraphQLView
from .schema import schema

urlpatterns = [
    ...,
    path("graphql", GraphQLView.as_view(schema=schema)),
]

Examples

Contributing

We use uv to manage dependencies, to get started follow these steps:

git clone https://github.com/strawberry-graphql/strawberry
cd strawberry
uv sync
uv run pytest

For all further detail, check out the Contributing Page

Pre commit

We have a configuration for pre-commit, to add the hook run the following command:

pre-commit install

Links

Licensing

The code in this project is licensed under MIT license. See LICENSE for more information.

Recent Activity

最近版本更新:(数据更新于 2026-04-16 07:07:03)

2026-04-09 02:04:52 0.314.3

2026-04-09 01:57:10 0.314.2

2026-04-08 17:49:41 0.314.1

2026-04-08 01:55:59 0.314.0

2026-04-06 18:06:17 0.313.0

2026-04-05 20:02:23 0.312.4

2026-04-04 20:08:57 0.312.3

2026-03-26 00:57:13 0.312.2

2026-03-26 00:54:32 0.312.1

2026-03-22 01:35:59 0.312.0

主题(topics):

asgi, asyncio, django, fastapi, graphql, graphql-library, graphql-schema, graphql-server, hacktoberfest, mypy, python, starlette, strawberry

strawberry-graphql/strawberry同语言 Python最近更新仓库

2026-04-18 20:31:49 PrimeIntellect-ai/verifiers

2026-04-18 10:24:54 seleniumbase/SeleniumBase

2026-04-18 08:21:06 pydantic/pydantic-ai

2026-04-18 06:13:38 microsoft/agent-framework

2026-04-18 04:59:46 mealie-recipes/mealie

2026-04-18 04:42:35 PostHog/posthog