MCPcopy
hub / github.com/strawberry-graphql/strawberry

github.com/strawberry-graphql/strawberry @0.320.1 sqlite

repository ↗ · DeepWiki ↗ · release 0.320.1 ↗
6,340 symbols 23,821 edges 729 files 537 documented · 8%
README

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

  • Project homepage: https://strawberry.rocks
  • Repository: https://github.com/strawberry-graphql/strawberry
  • Issue tracker: https://github.com/strawberry-graphql/strawberry/issues
  • In case of sensitive bugs like security vulnerabilities, please contact patrick.arminio@gmail.com directly instead of using the issue tracker. We value your effort to improve the security and privacy of this project!

Licensing

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

Recent Activity

Extension points exported contracts — how you extend this code

ApolloSubscriptionTestProps (Interface)
(no doc)
e2e/src/components/subscription-tests.tsx
ApolloQueryWrapperProps (Interface)
(no doc)
e2e/src/components/apollo-tests.tsx
RelayQueryWrapperProps (Interface)
(no doc)
e2e/src/components/relay-tests.tsx

Core symbols most depended-on inside this repo

execute_sync
called by 568
strawberry/schema/schema.py
to_base64
called by 169
strawberry/relay/utils.py
receive_json
called by 150
tests/http/clients/base.py
get_object_definition
called by 141
strawberry/types/base.py
cast
called by 114
strawberry/types/cast.py
execute
called by 114
strawberry/schema/schema.py
get
called by 108
strawberry/sanic/views.py
send_message
called by 89
tests/http/clients/base.py

Shape

Function 2,616
Method 1,994
Class 1,658
Route 67
Interface 3
Enum 2

Languages

Python99%
TypeScript1%

Modules by API surface

tests/experimental/pydantic/test_conversion.py91 symbols
tests/schema/test_generics.py89 symbols
tests/schema/test_union.py87 symbols
tests/python_312/test_generics_schema.py81 symbols
tests/schema/extensions/schema_extensions/test_extensions.py80 symbols
tests/websockets/test_graphql_transport_ws.py73 symbols
tests/fields/test_resolvers.py72 symbols
tests/experimental/pydantic/test_basic.py69 symbols
tests/schema/test_resolvers.py66 symbols
tests/schema/test_maybe.py61 symbols
tests/types/test_object_types.py60 symbols
tests/schema/test_basic.py57 symbols

Dependencies from manifests, versioned

@apollo/client4.0.11 · 1×
@eslint/js10.0.1 · 1×
@playwright/test1.54.1 · 1×
@radix-ui/react-slot1.2.3 · 1×
@tailwindcss/vite4.1.11 · 1×
@types/node26.0.0 · 1×
@types/react19.1.8 · 1×
@types/react-dom19.1.6 · 1×
@types/react-relay18.2.1 · 1×
@types/relay-runtime20.1.1 · 1×
@vitejs/plugin-react6.0.0 · 1×
babel-plugin-relay21.0.1 · 1×

For agents

$ claude mcp add strawberry \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact