Skip to content

FastGraphQL

FastGraphQL

FastGraphQL is a tool for creating code-driven GraphQL APIs.


pypi Python Versions License

codecov tests

Code Smells Security Rating Maintainability Rating Vulnerabilities Bugs Duplicated Lines (%) Technical Debt


Documentation: https://hugowschneider.github.io/fastgraphql

Source Code: https://github.com/hugowschneider/fastgraphql

Disclaimer

This is still a work in progress and all support is welcomed

Motivation

So far most of the projects that use GraphQL need to duplicate many definitions to be able to have a consistent GraphQL API schema alongside well-defined models that governs the development and the application.

FastGraphQL proposes to shortcut the path between python models and GraphQL schema using Pydantic models. This ensures not only a single source of truth when comes to type, input, query and mutation definitions, but also the ability to use Pydantic to features on models and inputs.

Installation

$ pip install "fastgraphql[all]"
You will also need an ASGI server as well to serve your API

$ pip install "uvicorn[standard]"

Usage

The very first Hello Work example.

main.py
from fastapi import FastAPI
from fastgraphql import FastGraphQL
from fastgraphql.fastapi import make_ariadne_fastapi_router

app = FastAPI()
fast_graphql = FastGraphQL()


@fast_graphql.query()
def hello() -> str:
    return "Hello FastGraphQL!!!"


app.include_router(make_ariadne_fastapi_router(fast_graphql=fast_graphql))
$ uvicorn main:app --reload

A simple example will not show you the all FastGraphQL capabilities, but it shows how simple this can be.

Learn

To start your journey into FastGraphQL, please refer to Getting Started.

You can find the API documentation here.

Integration

FastGraphQL generates independently of any integration a data structure containing all GraphQL definitions and resolvers, which generates a GraphQL schema.

With that said, all integration will add functionalities and provide easy and alternative deployments of the defined API.

You can find out more about the different integrations under Integrations

Acknowledgment

Thanks to FastAPI for the inspiration!