Skip to main content

Framework for automatic GraphQL testing

Project description


Framework for automatic GraphQL testing. The framework takes url of your GraphQL endpoint, builds schema and generates http queries for testing.


pip3 install gqltst


Prepare your schema

    import gqltst
    schema = gqltst.Schema("")

There're already prepared resolvers for Integer, String, Boolean, DateTime and Float, but you can register own resolver for your scalars.

    from gqltst.types import BaseResolver

    class YourResolver(BaseResolver):  
	    def resolve(self, context):  
	        yield "Hello world"

	    def escape(self, value):  
	        return "\"%s\"" % (str(value))  

	    def validate(self, data):  
	        return type(data) == int 

    schema.register_scalar("Myscalar", YourResolver)

Start test with own parameter resolvers

    from gqltst.reslovers import range_resolver, depend_resolver
    from datetime import datetime, timedelta
    from gqltst.types import ValidationResult

    def date_resolver(context):
        now_date =
        for generated_date in [(now_date - timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S"),
                                (now_date - timedelta(days=2)).strftime("%Y-%m-%d %H:%M:%S")]:
            yield generated_date

    args = {
        "environment": {
            "token": range_resolver(["token1", "token2"]),
            "search": {
                "items": {
                    "name": range_resolver(["name1", None, "name3"]),
                    "surname": depend_resolver("$environment_search_items_name", None, ["A", "B"], [None]),
                    "dateFrom": date_resolver,
                    "records": {
                        "first": range_resolver([0]),
                        "step": range_resolver([1]),

    def test_validator(data, node):
        if data == "Paul":
            return [ValidationResult("It's not our manager", node, data))]
            return []

    validators = {
        "environment.items.surname": [

    schema.test(args=args, validators=validators)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for gqltst, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size gqltst-0.0.4-py3-none-any.whl (8.2 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page