API reference

Submodules

wagtail_graphql.apps module

class wagtail_graphql.apps.WagtailGraphQLConfig(app_name, app_module)

Bases: django.apps.config.AppConfig

name = 'wagtail_graphql'
ready()

Override this method in subclasses to run code when Django starts.

wagtail_graphql.checks module

wagtail_graphql.checks.check_settings(app_configs, **kwargs)
wagtail_graphql.checks.register_checks()

wagtail_graphql.converters module

wagtail_graphql.converters.convert_stream_field(field, _registry=None)

Register a GraphQL scalar for the Wagtail’s StreamValue.

wagtail_graphql.converters.convert_tags_to_list_of_strings(field, _registry=None)

Register a GraphQL scalar for the TaggableManager used by Wagtail.

wagtail_graphql.converters.register_converters()

Register the custom converters in the graphene-django’s registry.

wagtail_graphql.models module

class wagtail_graphql.models.GraphQLEnabledModel

Bases: object

Subclass used by all the models that are dynamically registered as a GraphQL object type.

class wagtail_graphql.models.GraphQLField(name, resolve_func=None, graphql_type=None)

Bases: object

Specify metadata about a model field that is to be registered at a GraphQL object type.

Parameters:
  • name – Name of the field.
  • resolve_func (callable) – A custom resolve function that will be used to resolve data for this field.
  • graphql_type – Graphene type that will be used by that field.
graphql_type
name
resolve_func

wagtail_graphql.schema module

class wagtail_graphql.schema.WagtailQuery(*args, **kwargs)

Bases: graphene.types.objecttype.ObjectType, wagtail_graphql.query_mixins.pages.PageQueryMixin, wagtail_graphql.query_mixins.snippets.EmptySnippetQueryMixin, wagtail_graphql.query_mixins.images.ImageQueryMixin, wagtail_graphql.query_mixins.sites.CurrentSiteMixin, wagtail_graphql.query_mixins.documents.DocumentQueryMixin

Main GraphQL query used directly by the endpoint.

wagtail_graphql.settings module

wagtail_graphql.settings.WAGTAIL_GRAPHQL_ADD_SEARCH_HIT = False

If search query is used in the API, a hit can be added to the Wagtail search Query object by setting this to True.

wagtail_graphql.settings.WAGTAIL_GRAPHQL_ALLOWED_RENDITION_FILTERS = ('fill-200x200', 'width-2000')

Specify a list of allowed image rendition filters that can be used in the API. Use ['*'] to disable the check.

wagtail_graphql.settings.WAGTAIL_GRAPHQL_DEFAULT_RENDITION_FILTER = 'original'

Specify default Wagtail’s image rendition filter used by the API if not specified explicitly.

wagtail_graphql.settings.WAGTAIL_GRAPHQL_ENABLE_DOCUMENTS = True

Enable documents list in the GraphQL schema.

wagtail_graphql.settings.WAGTAIL_GRAPHQL_ENABLE_IMAGES = True

Enable images list in the GraphQL schema.

wagtail_graphql.settings.reload_settings(**kwargs)
wagtail_graphql.settings.set_settings()

wagtail_graphql.utils module

wagtail_graphql.utils.exclude_invisible_pages(request, pages)

Exclude from the QuerySet of pages that are invisible for the current user.

Parameters:
  • request (django.http.request.HttpRequest) – Request used to authorize access to pages.
  • pages – QuerySet containing pages to filter.
wagtail_graphql.utils.exclude_restricted_collection_members(request, collection_members)

Filter out a list of Wagtail collection members (e.g. images or documents) that have collection privacy set accordingly.

Parameters:
  • request (django.http.request.HttpRequest) – Request used to authorize access to pages.
  • pages – QuerySet containing pages to filter.
wagtail_graphql.utils.get_base_queryset_for_model_or_qs(model_or_qs, info, **kwargs)

Process a query set before displaying it in the GraphQL query result.

Parameters:
  • model_or_qs – Model or a query set to be transformer.
  • info – Graphene’s info object.
  • kwargs – Any additional keyword arguments passed from the GraphQL query.
wagtail_graphql.utils.get_base_queryset_for_page_model_or_qs(page_model_or_qs, info, **kwargs)

The same as get_base_queryset_for_model_or_qs(), except it adds Wagtail page-specific filters and privacy checks.

Parameters:
  • model_or_qs – Model or a query set to be transformer.
  • info – Graphene’s info object.
  • kwargs – Any additional keyword arguments passed from the GraphQL query.
wagtail_graphql.utils.model_to_qs(model_or_qs)

Convert model to a query set if it is not already a query set.

Parameters:model_or_qs – Model or query set to be cast as a query set.
wagtail_graphql.utils.resolve_absolute_url(url, request, absolute=True)

Transform URL to an absolute one if it already is not absolute.

Parameters:
  • url (str) – The URL to be resolved, relative or absolute.
  • request (django.http.request.HttpRequest) – Request used to get the domain.
  • absolute (bool) – Set to True if value should be returned as absolute.
wagtail_graphql.utils.resolve_queryset(qs, info, limit=None, offset=None, search_query=None, id=None, order=None, **kwargs)

Add limit, offset and search capabilities to the query. This contains argument names used by QuerySetList.

Parameters:
  • qs – Query set to be modified.
  • info – Graphene’s info object.
  • limit (int) – Limit number of objects in the QuerySet.
  • id – Filter by the primary key.
  • offset (int) – Omit a number of objects from the beggining of the query set
  • search_query (str) – Using wagtail search exclude objects that do not match the search query.
  • order (str) – Use Django ordering format to order the query set.

Module contents

wagtail-graphql-api

class wagtail_graphql.GraphQLEnabledModel

Bases: object

Subclass used by all the models that are dynamically registered as a GraphQL object type.

class wagtail_graphql.GraphQLField(name, resolve_func=None, graphql_type=None)

Bases: object

Specify metadata about a model field that is to be registered at a GraphQL object type.

Parameters:
  • name – Name of the field.
  • resolve_func (callable) – A custom resolve function that will be used to resolve data for this field.
  • graphql_type – Graphene type that will be used by that field.
graphql_type
name
resolve_func