Codegen Python GraphQL Entity Framework
Project description
Platformics
Platformics is a GraphQL API framework that relies on code generation to implement a full featured GraphQL API on top of a PostgreSQL database, with support for authorization policy enforcement and file persistence via S3. It's built on top of the best available Python tools and frameworks!
The libraries and tools that make Platformics work:
Links to these tools/libraries
- LinkML - Schema modeling language
- FastAPI - Async HTTP router
- Strawberry - GraphQL Framework
- Pydantic - Data validation
- Cerbos - Authorization
- SQLAlchemy - Database Access / ORM
- factory_boy - Test fixtures
- Alembic - Database migrations
Current Features
- Express your schema in a straightforward YAML format
- GraphQL Dataloader pattern (no n+1 queries!)
- Authorization policy enforcement
- Flexible Filtering
- Data aggregation
- Top-level pagination
- Relationship traversal
- DB migrations
- Generated Test fixtures
- pytest wiring
- VSCode debugger integration
- Authorized S3 file up/downloads
- Add custom REST endpoints to generated API
- Add custom GQL queries/mutations to generated API
Roadmap
- Plugin hooks to add business logic to generated GQL resolvers
- Support arbitrary class inheritance hierarchies
- Package and publish to PyPI
How to set up your own platformics API
- Copy the test_app boilerplate code to your own repository.
- Edit
schema/schema.yml
to reflect your application's data model. - Run
make build
and thenmake init
to build and run your own GraphQL API service. - Browse to http://localhost:9009/graphql to interact with your api!
- Run
make token
to generate an authorization token that you can use to interact with the API. Themake
target copies the necessary headers to the system clipboard. Paste the token into theheaders
section at the bottom of the GraphQL explorer API
Versioning platformics
Platformics can be used in downstream applications by
- using the platformics image as the base Docker image. To select a version of platformics, add the appropriate version tags to the docker image
- installing as a dependency,
pip install platformics
.
The version in pyproject.toml
is managed using poetry-dynamic-versioning which determines version based on git tags.
Iterating on your schema
- Make changes to
schema/schema.yml
- Run
make codegen
to re-run code gen and restart the API service - If your changes require DB schema changes, run
make alembic-autogenerate
andmake alembic-upgrade-head
to generate DB migrations and run them.
HOWTO
Contributing
This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to opensource@chanzuckerberg.com.
Reporting Security Issues
Please disclose security issues responsibly by contacting security@chanzuckerberg.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file platformics-0.1.0.tar.gz
.
File metadata
- Download URL: platformics-0.1.0.tar.gz
- Upload date:
- Size: 59.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5370199fa568425603d51c0e611ac3c1b8577ec9096d7e2afa5f93b18fcba0a |
|
MD5 | e53214f1047cdd3ebfc88357e7e366c2 |
|
BLAKE2b-256 | f0ac078cadf3860b77f12cb95f9560da0b2aa6f020d41e2fafc8b5ebf062d752 |
File details
Details for the file platformics-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: platformics-0.1.0-py3-none-any.whl
- Upload date:
- Size: 78.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41f2fe616c33229557cd9732d780439bd1a469f4baeda468d8ea00bb1bd3a5a5 |
|
MD5 | d0d0a5e849d477897121d1d5343e3c6b |
|
BLAKE2b-256 | 8f692922765e8efcfeef21ed6d9f5a6b1469b0c288b5d457323dfd58c12b3df3 |