Skip to content

WIP: Add initial readonly support for GraphQL.

Abhilash Raj requested to merge maxking/mailman:graphql into master

An experimental branch to explore how the support for GraphQL would look like. This currrently only exposes the data model through the /graphql endpoint and can be used to fetch data for defined models.

This API can be tested by writing GraphQL queries, for example, to get a list of all the MailingLists:

{
  allMailinglists {
    edges {
      node {
        listName
        mailHost
        allowListPosts
        includeRfc2369Headers
        advertised
        anonymousList
      }
    }
  }
}

This query can be executed by putting it into a file like mailinglist.txt and running the query via curl:

$ curl -X POST -H "Content-Type: application/graphql" \
--data @mailinglists.txt \
-u restadmin:restpass http://localhost:8001/graphql | python -m json.tool
{
    "data": {
        "allMailinglists": {
            "edges": [
                {
                    "node": {
                        "listName": "\"list\"",
                        "mailHost": "\"example.com\"",
                        "allowListPosts": true,
                        "includeRfc2369Headers": true,
                        "advertised": true,
                        "anonymousList": false
                    }
                },
                {
                    "node": {
                        "listName": "\"as\"",
                        "mailHost": "\"example.com\"",
                        "allowListPosts": false,
                        "includeRfc2369Headers": true,
                        "advertised": true,
                        "anonymousList": false
                    }
                },
                {
                    "node": {
                        "listName": "\"somelist\"",
                        "mailHost": "\"example.com\"",
                        "allowListPosts": false,
                        "includeRfc2369Headers": true,
                        "advertised": true,
                        "anonymousList": false
                    }
                }
            ]
        },
    }
}

You have to specify all the fields that you need explicitly in the query.

Edited by Abhilash Raj

Merge request reports