Skip to main content

Overview

strawberry-autograph is a testing library designed to extend Strawberry's test client capabilities by automatically generating operation strings for queries and mutations. This allows for streamlined testing of GraphQL schemas, focusing on testing schema logic directly with Strawberry input objects.

Installation

Add strawberry-autograph to your project using Poetry or pip:

poetry add strawberry-autograph

or

pip install strawberry-autograph

Ensure you have Strawberry GraphQL installed as it's an optional dependency:

poetry add strawberry-graphql

Features

  • Operation Autogeneration: Dynamically creates operation strings for testing.
  • Seamless Integration: Wraps around Strawberry's test client, enhancing its functionality.

Usage

strawberry-autograph simplifies writing tests for Strawberry schemas by using defined inputs directly in test cases.

Testing Mutations with Inputs

Define your schema with a mutation that takes a Strawberry input:

import strawberry

@strawberry.input
class CookEggInput:
    minutes: int

@strawberry.type
class Mutation:
    @strawberry.mutation
    def cook_egg(self, egg_op: CookEggInput) -> str:
        return "cooked" if input.minutes > 3 else "raw"

schema = strawberry.Schema(mutation=Mutation)

Use strawberry-autograph to automatically generate the mutation operation string and execute it with the Strawberry test client:

from strawberry_autograph import AutoGraphClient
from myapp.schema import schema  # Your Strawberry graphql schema object

def test_cook_egg():
    client = AutoGraphClient(schema)
    result = client.cook_egg(
        egg_op=CookEggInput(minutes=4)
    )
    assert result.data == {"cookEgg": "cooked"}

This library enables focused and efficient testing of GraphQL logic, directly utilizing Strawberry types and inputs.

Development Status

strawberry-autograph is currently in alpha (v0.1.0) and open to contributions. As an evolving project, feedback and improvements are welcome to refine its functionality and user experience.

Metadata

Release files for strawberry-autograph 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strawberry-autograph 0.1.0
File Size Uploaded Provenance Actions
strawberry_autograph-0.1.0.tar.gz 5.4 kB Without provenance Details for strawberry_autograph-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for strawberry-autograph 0.1.0
File Interpreter ABI Platform Actions
strawberry_autograph-0.1.0-py3-none-any.whl Python 3 none any Details for strawberry_autograph-0.1.0-py3-none-any.whl

Total release size: 11.4 kB

Release files / strawberry_autograph-0.1.0.tar.gz

Download URL strawberry_autograph-0.1.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
43d481f472b7047d93c738cdaab3720f3fab744b0203cadb745d2134c97fd651
BLAKE2b-256 checksum
How to use checksums
40b7881279dfddb50a04b3beeeda86a1a1ed031e979799f50301cf5dfe21d976
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.6 Darwin/23.2.0

Release files / strawberry_autograph-0.1.0-py3-none-any.whl

Download URL strawberry_autograph-0.1.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5457bb98b88d8bc7e290004dfa7b69c3617034c741e3958ea12eaa09e3af4805
BLAKE2b-256 checksum
How to use checksums
a691c951ea27309bffdb556b52c0b5b405cf59c2b3279c5a641370a8e8bc3a73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.6 Darwin/23.2.0

Security for strawberry-autograph 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page