All Projects → tr11 → wagtail-graphql

tr11 / wagtail-graphql

Licence: MIT license
App to automatically add GraphQL support to a Wagtail website

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to wagtail-graphql

wagtailenforcer
The Wagtail arm of the law - enforce security protocols on your Wagtail site
Stars: ✭ 43 (+16.22%)
Mutual labels:  wagtail
wagtail-sharing
Easier sharing of Wagtail drafts
Stars: ✭ 46 (+24.32%)
Mutual labels:  wagtail
graphene-django-cud
Easy and painless CUD-mutations for graphene-django.
Stars: ✭ 66 (+78.38%)
Mutual labels:  graphene
wagtail-redirect-importer
Note: This library is now included in Wagtail 2.10, use the builtin version instead of this.
Stars: ✭ 15 (-59.46%)
Mutual labels:  wagtail
jakartaee-faces-sample
Jakarta EE 10 Faces Example
Stars: ✭ 20 (-45.95%)
Mutual labels:  graphene
gql-next
A Python GraphQL Client library providing ability to validate and make type-safe GraphQL calls
Stars: ✭ 74 (+100%)
Mutual labels:  graphene
wagtail-headless-preview
Previews for headless Wagtail setups
Stars: ✭ 99 (+167.57%)
Mutual labels:  wagtail
wagtail-simple-gallery
A simple gallery app for Wagtail. https://pypi.org/project/wagtail-simple-gallery/
Stars: ✭ 41 (+10.81%)
Mutual labels:  wagtail
graphene django crud
Turns the django ORM into a graphql API
Stars: ✭ 23 (-37.84%)
Mutual labels:  graphene
wagtail-import-export
UNMAINTAINED. Try wagtail-transfer, the evolution of this package: https://github.com/wagtail/wagtail-transfer/
Stars: ✭ 31 (-16.22%)
Mutual labels:  wagtail
wagtaildraftail
🐦📝🍸 Draft.js editor for Wagtail, built upon Draftail and draftjs_exporter
Stars: ✭ 23 (-37.84%)
Mutual labels:  wagtail
WF-website
Website for Western Friend, part of the Religious Society of Friends
Stars: ✭ 34 (-8.11%)
Mutual labels:  wagtail
wagtailmodelchoosers
A Wagtail app to pick generic models (rather than snippets or pages)
Stars: ✭ 23 (-37.84%)
Mutual labels:  wagtail
vagrant-wagtail-develop
A script to painlessly set up a Vagrant environment for development of Wagtail
Stars: ✭ 36 (-2.7%)
Mutual labels:  wagtail
wagtail-react-project
Wagtail template with a React/Redux frontend.
Stars: ✭ 25 (-32.43%)
Mutual labels:  wagtail
digihel
City of Helsinki Digital Helsinki Wagtail CMS
Stars: ✭ 19 (-48.65%)
Mutual labels:  wagtail
wagtail-filepreviews
Extend Wagtail's Documents with image previews and metadata from FilePreviews
Stars: ✭ 21 (-43.24%)
Mutual labels:  wagtail
graphene-elastic
Graphene Elasticsearch/OpenSearch (DSL) integration
Stars: ✭ 68 (+83.78%)
Mutual labels:  graphene
gatsby-source-wagtail
Plugin for sourcing Gatsby data from Wagtail CMS
Stars: ✭ 16 (-56.76%)
Mutual labels:  wagtail
Flask-GraphQL-Graphene-MySQL-Docker-StarterKit
Reference Repository for the article
Stars: ✭ 28 (-24.32%)
Mutual labels:  graphene

    


wagtail-graphql

An app to automatically add GraphQL support to a Wagtail website

This Wagtail app adds GraphQL types to other Wagtail apps. The objective is for this library to interact with an existing website in a generic way and with minimal effort. In particular, it makes minimal assumptions about the structure of the website to allow for a generic API.

Installing / Getting started

To install as a general app:

pip install wagtail-graphql

Add it together with graphene_django to the Django INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'wagtail_graphql',
    'graphene_django',
    ...
]

Initial Configuration

Add the required graphene schema GRAPHENE and a GRAPHQL_API dictionary. Include all the Wagtail apps the library should generate bindings to in the APPS list and optionally specify the prefix for each app in PREFIX. To remove a leading part of all the urls for a specific site, specify the URL_PREFIX parameter for each needed host.

GRAPHENE = {
    'SCHEMA': 'wagtail_graphql.schema.schema',
}

GRAPHQL_API = {
    'APPS': [
        'home'
    ],
    'PREFIX': {
        'home': ''        # optional, prefix for all the app classes generated by the wrapper
    },
    'URL_PREFIX': {
        'localhost': '/home'   # optional, read from the site information if not specified 
    }
}

The example above generates bindings for the home app, . Every url in this example will be stripped of the initial /home substring.

Finally, set up the GraphQL views in the project urls.py. For example, to add two endpoints for GraphQL and the GraphiQL IDE:

from django.views.decorators.csrf import csrf_exempt
from graphene_django.views import GraphQLView

urlpatterns = [
    ...
    url(r'^api/graphql', csrf_exempt(GraphQLView.as_view())),
    url(r'^api/graphiql', csrf_exempt(GraphQLView.as_view(graphiql=True, pretty=True)),
    ...
]

Note that the urls above need to appear before the wagtail_urls catchall entry.

Images

To be able to generate urls for images the following also needs to be included in the project's urls.py:

from wagtail.images.views.serve import ServeView

urlpatterns = [
    ...
    url(r'^images/([^/]*)/(\d*)/([^/]*)/[^/]*$', ServeView.as_view(), name='wagtailimages_serve'),
    ...
]

Multi-site configuration

This library works transparently with a multi-site Wagtail install without any extra configuration required. To strip a custom leading prefix for each site, specify each host in the URL_PREFIX. For exaple, for two hosts host1.example.com and host2.example.com:

GRAPHQL_API = {
    ...
    'URL_PREFIX': {
        'host1.example.com': '/prefix1',
        'host2.example.com': '/prefix2'
    }
    ...
}

Note that the prefix for a site is taken from the root page url if a host is not included in the URL_PREFIX dictionary.

Developing

To develop this library, download the source code and install a local version in your Wagtail website.

Features

This project is intended to require minimal configuration and interaction. It currently supports

Contributing

If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome.

Links

Licensing

The code in this project is licensed under MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].