在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):tr11/wagtail-graphql开源软件地址(OpenSource Url):https://github.com/tr11/wagtail-graphql开源编程语言(OpenSource Language):Python 99.2%开源软件介绍(OpenSource Introduction):wagtail-graphql
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 startedTo 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 ConfigurationAdd the required graphene schema 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 Finally, set up the GraphQL views in the project 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 ImagesTo be able to generate urls for images the following also needs to be included in the project's from wagtail.images.views.serve import ServeView
urlpatterns = [
...
url(r'^images/([^/]*)/(\d*)/([^/]*)/[^/]*$', ServeView.as_view(), name='wagtailimages_serve'),
...
] Multi-site configurationThis 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
Note that the prefix for a site is taken from the root page url if a host is not included in the DevelopingTo develop this library, download the source code and install a local version in your Wagtail website. FeaturesThis project is intended to require minimal configuration and interaction. It currently supports
ContributingIf you'd like to contribute, please fork the repository and use a feature branch. Pull requests are welcome. Links
LicensingThe code in this project is licensed under MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论