README.rst
author Laurent Wouters <lwouters@cenotelie.fr>
Wed, 29 Apr 2020 15:22:49 +0200
changeset 17 b792134b6f43
parent 11 d6b087e8c925
permissions -rw-r--r--
Fix flaky test due to different behaviors between cubicweb versions 3.26.14 and 3.26.17

===================
cubicweb-graphql
===================

`cubicweb-graphql`_ provides a `GraphQL`_ interface and querier for CubicWeb.

.. _`GraphQL`: \
    https://graphql.org/


Basic use in Python
-------------------

Once the CubicWeb instance has been launched, GraphQL queries can be executed using:

::

    from cubicweb_graphql.querier import GraphQLQuerier

    query = "query getAffaire($affaire_eid: ID) { Affaire(eid: $affaire_eid) { sujet } }"
    result = GraphQLQuerier.execute(connection, query, affaire_eid=self.affaire1)


Access from the Web API
-----------------------

The GraphQL querier can be access through the Web API:

::

    curl "http://localhost:8080/ajax" \
            -d "fname=graphql" \
            -d "query=$QUERY" \

.

Testing
-------

Tests can be run using:

::

    python -m unittest discover -s test

from top-level directory.