Odoo GraphQL Subscription

by
Odoo

118.46

v 17.0 Third Party 1
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Discuss (mail)
Community Apps Dependencies
Lines of code 2998
Technical Name easy_graphql_subscription
LicenseOPL-1
Websitehttps://ekika.co
Versions 16.0 17.0
You bought this module and need support? Click here!
Availability
Odoo Online
Odoo.sh
On Premise
Odoo Apps Dependencies Discuss (mail)
Community Apps Dependencies
Lines of code 2998
Technical Name easy_graphql_subscription
LicenseOPL-1
Websitehttps://ekika.co
Versions 16.0 17.0


Introduction

This module specifically introduces GraphQL subscription functionality as a key feature.

All screenshot in this page is with main framework module. If you not buy api_framework module and buy this module you will get only graphql. You will not get json:api.

Main API Bundle Module: API Framework


Note: Headers supported by GraphQL subscription websocket clients will work; others will not work.(We use various authentication methods during a handshake call that depend on multiple factors, i.e., headers for API key-based authentication.) Subscription introspection will work, but subscription connections will not be established as it may depend on headers, and some introspection tools are not sending headers with websocket subscription calls.

How It Works

  • First, you have to create record of GraphQL Subscription, which includes subscription-name, model and for which operations(create, write, delete) you want to use this subscription.

    GraphQL-Read

  • Then run subscription with above created subscription name like below example:

    GraphQL-Read

  • After that any change made related to this subscription it will show like below example.

    GraphQL-Read

GraphQL Subscription API Calls:

Below are examples using postman:

GraphQL-Read

GraphQL-Read

GraphQL-Read

Setup instruction

Only Applicable for GraphQL Subscription.

Odoo setup instruction when configured behind the nginx proxy.


  map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
  }

  server {
    # Your existing server configuration...

    # Set HTTP version to 1.1
    proxy_http_version 1.1;

    # Set headers for WebSocket upgrade
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    # Your GraphQL subscription endpoint location.
    # This is required when you use a worker (gevent) based Odoo server.
    location /graphql-subscription-endpoint {
        # Proxy pass to the Odoo server running on localhost at port 8072.
        # 8072 is gevent_port should be defined in odoo configuration file.
        proxy_pass http://127.0.0.1:8072;

        # Set headers for WebSocket upgrade
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;

        # Set headers for forwarding request details
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }

    # Your other server configurations...
  }

Explanation:

  • proxy_http_version 1.1;: Sets the HTTP version to 1.1 for proxy connections.

  • proxy_set_header Upgrade $http_upgrade;: Sets the Upgrade header to $http_upgrade, enabling WebSocket upgrade support.

  • proxy_set_header Connection “upgrade”;: Sets the Connection header to “upgrade” to signal WebSocket connection upgrade.

  • location /graphql-subscription-endpoint { … }: Defines a location block for handling requests to the GraphQL subscription endpoint.

  • proxy_pass http://127.0.0.1:8072;: Forwards requests to the Odoo server running on http://127.0.0.1:8072.

  • proxy_set_header X-Forwarded-Host $host;: Sets the X-Forwarded-Host header to the value of $host, indicating the original host requested by the client.

  • proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;: Appends the client's IP address to the X-Forwarded-For header to indicate the client's original IP.

  • proxy_set_header X-Forwarded-Proto $scheme;: Sets the X-Forwarded-Proto header to the value of $scheme, indicating the protocol used by the client (HTTP or HTTPS).

  • proxy_set_header X-Real-IP $remote_addr;: Sets the X-Real-IP header to the client's IP address, providing the real IP of the client to the backend server.

Odoo Proprietary License v1.0

This software and associated files (the "Software") may only be used (executed,
modified, executed after modifications) if you have purchased a valid license
from the authors, typically via Odoo Apps, or if you have received a written
agreement from the authors of the Software (see the COPYRIGHT file).

You may develop Odoo modules that use the Software as a library (typically
by depending on it, importing it and using its resources), but without copying
any source code or material from the Software. You may distribute those
modules under the license of your choice, provided that this license is
compatible with the terms of the Odoo Proprietary License (For example:
LGPL, MIT, or proprietary licenses similar to this one).

It is forbidden to publish, distribute, sublicense, or sell copies of the Software
or modified copies of the Software.

The above copyright notice and this permission notice must be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

Please log in to comment on this module

  • The author can leave a single reply to each comment.
  • This section is meant to ask simple questions or leave a rating. Every report of a problem experienced while using the module should be addressed to the author directly (refer to the following point).
  • If you want to start a discussion with the author or have a question related to your purchase, please use the support page.