Package: wagtail-bifrost
Wagtail BifrostA library to build GraphQL endpoints easily so you can bifrost your Wagtail data from anywhere!Explore the docs »View Demo·Report Bug·Request FeatureTable of ContentsAbout the ProjectBuilt WithGetting StartedPrerequisitesInstallationUsageContributingCompatibilityLicenseContactAcknowledgementsAbout The ProjectThere is a range of GraphQL packages for Python and specifically Django.
However, getting these packages to work out of the box with an existing infrastructure
without errors isn't as easy to come by.The purpose of Bifrost is to be able to build GraphQL endpoints on a model by model
basis as quickly as possible. The setup and configuration have been designed
to be as simple but also provide the best features;
No complex serializers need to be written - just add agraphql_fieldslist
to your model and away you go (although if you want to go deeper you can!).Features:Easily create GraphQL types by adding a small annotation in your models.Supports traditional Wagtail models:Pages (including Streamfield & Orderables)SnippetsImagesDocumentsSettingsSearch (on all models)Custom Image & Document model supportAdvanced headless preview functionality buit using GraphQL Subscriptions to enable Page previews on any device!Gatsby Image support (both base64 and SVG tracing)! :fire:Built WithThis library is an abstraction upon and relies heavily on Graphene & Graphene Django.
We also use Django Channels and the Potrace image library.GrapheneGraphene DjangoDjango ChannelsPotraceGetting StartedGetting Bifrost installed is designed to be as simple as possible!PrerequisitesDjango  >= 2.2, <2.3
wagtail >= 2.5, <2.8Installationpip install wagtail_bifrostAdd the following to theinstalled_appslist in your Wagtail settings file:installed_apps=[..."bifrost","graphene_django","channels",...]Add the following to the bottom of the same settings file, where each key is the app you want to this library to scan and the value is the prefix you want to give to GraphQL types (you can usually leave this blank):# Bifrost Config:GRAPHENE={"SCHEMA":"bifrost.schema.schema"}BIFROST_APPS={"home":""}Add the GraphQL URLs to yoururls.py:frombifrostimporturlsasbifrost_urls...urlpatterns=[...url(r"",include(bifrost_urls)),...]Done! Now you can proceed onto configuring your models to generate GraphQL types that adopt their stucture :tada:
_Your graphql endpoint is available at http://localhost:8000/graphql/_UsageHere is a GraphQL model configuration for the default page from the Wagtail docs:...frombifrost.modelsimport(GraphQLString,GraphQLStreamfield,)classBlogPage(Page):author=models.CharField(max_length=255)date=models.DateField("Post date")body=StreamField([("heading",blocks.CharBlock(classname="full title")),("paraagraph",blocks.RichTextBlock()),("image",ImageChooserBlock()),])content_panels=Page.content_panels+[FieldPanel("author"),FieldPanel("date"),StreamFieldPanel("body"),]# Note these fields below:graphql_fields=[GraphQLString("heading"),GraphQLString("date"),GraphQLString("author"),GraphQLStreamfield("body"),]For more examples, please refer to theDocumentationContributingContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make aregreatly appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature)Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLocal developmentIn the python environment of your choice, navigate to/examplesRunpip install -r requirements.txtDelete thedb.sqlite3file and run./manage.py migrateRun server./manage.py runserverCompatibilityWagtail Bifrost supports:Django 2.2.xPython 3.6 and 3.7Wagtail >= 2.5LicenseDistributed under the MIT License. SeeLICENSEfor more information.ContactNathan Horrigan@NathHorriganNathHorrigan@gmail.comProject Link:https://github.com/torchbox/wagtail-bifrostInspired by@tr11@tmkn