Graphql Base

Graphql Base

by Contaura LLC · original work by ACSONE SA/NV, OCA
graphql_base
$ 29.00

Base GraphQL/GraphiQL controller

1.0

One purchase covers every version. Already bought it? Sign in.

Graphql Base

This modules enables the creation of GraphQL endpoints. In itself, it does nothing and must be used by a developer to create the GraphQL schema and resolvers using graphene, and expose them through a controller. An example is available in the graphql_demo module.

Table of contents

Usage

To use this module, you need to

  • create your graphene schema
  • create your controller to expose your GraphQL endpoint, and optionally a GraphiQL IDE.

This module does not attempt to expose the whole Tulio object model. This could be the purpose of another module based on this one. We believe however that it is preferable to expose a specific well tested endpoint for each customer, so as to reduce coupling by knowing precisely what is exposed and needs to be tested when upgrading Tulio.

To start working with this module, we recommend the following approach:

  • Learn GraphQL basics
  • Learn graphene, the python library used to create GraphQL schemas and resolvers.
  • Examine the graphql_demo module in this repo, copy it, adapt the controller to suit your needs (routes, authentication methods).
  • Start building your own schema and resolver.

Building your schema

The schema can be built using native graphene types. An tulio.addons.graphql_base.types.OdooObjectType is provided as a convenience. It is a graphene ObjectType with a default attribute resolver which:

  • converts False to None (except for Boolean types), to avoid Tulio’s weird False strings being rendered as json "false";
  • adds the user timezone to Datetime fields;
  • raises an error if an attribute is absent to avoid field name typing errors.

Creating GraphQL controllers

The module provides an tulio.addons.graphql_base.GraphQLControllerMixin class to help you build GraphQL controllers providing GraphiQL and/or GraphQL endpoints.

from tulio import http
from tulio.addons.graphql_base import GraphQLControllerMixin

from ..schema import schema


class GraphQLController(http.Controller, GraphQLControllerMixin):

    # The GraphiQL route, providing an IDE for developers
    @http.route("/graphiql/demo", auth="user")
    def graphiql(self, **kwargs):
        return self._handle_graphiql_request(schema)

    # Optional monkey patch, needed to accept application/json GraphQL
    # requests. If you only need to accept GET requests or POST
    # with application/x-www-form-urlencoded content,
    # this is not necessary.
    GraphQLControllerMixin.patch_for_json("^/graphql/demo/?$")

    # The graphql route, for applications.
    # Note csrf=False: you may want to apply extra security
    # (such as origin restrictions) to this route.
    @http.route("/graphql/demo", auth="user", csrf=False)
    def graphql(self, **kwargs):
        return self._handle_graphql_request(schema)
Technical namegraphql_base
Module version12.0.2.0.1
Tulio versions1.0
CategoryTools
PublisherContaura LLC
Ported to Tulio, tested and supported by Contaura LLC.
Original authorsACSONE SA/NV, OCA
LicenseLGPL-3
Open source: you may use, change and share this module under its license. The price covers the Tulio port, its testing on Tulio 1.0 and the download.
Python librariesgraphene, graphql_server
Install them on the server with pip before installing the module.
Requires (Tulio core)base
Lines of code289
Downloads0
Released12/06/2026
12.0.2.0.1 Tulio 1.0 · 12/06/2026