DEV Community

Cover image for RealmQL an "alternative" to GraphQL
Giorgi Kavrelishvili
Giorgi Kavrelishvili

Posted on

RealmQL an "alternative" to GraphQL

RealmQL is a GraphQL "alternative" single end-point OM (Object Mapper) which acts as a query language. RealmQL maps the objects to the Realm database and stores them locally.

RealmQL is still in its early stage of development, and it would be wonderful if any of you could contribute to it !

Some example commands are described below:

CREATE

Creates a schema model with the provided values

{
    "Person": {
        "firstName": "John",
        "lastName" : "Doe"
    }
}

Creates a schema model with a nested model, first you need to create the object, which will be linked to this one

{
    "License": {
        "privateId": "randomString"
    }
}

And then link it to the person

{
    "Person": {
        "firstName": "John",
        "lastName" : "Doe",
        "license": {"id": 1}
    }
}

READ

Reads the schema model for specific values and returns it as an object

{
    "Person": {
        "id": 1,
        "values": ["firstName", "lastName"]
    }
}

Reads the schema model for values and returns it as an object

{
    "Person": {
        "id": 1,
        "values": ["*"]
    }
}

Reads the schema model for specific nested model values and returns it as an object

{
    "Person": {
        "id": 1,
        "values": [
            "*",
            {"license": ["privateId"]}
        ]
    }
}

Reads the schema model for nested model values and returns it as an object

{
    "Person": {
        "id": 1,
        "values": [
            "*",
            {"license": ["*"]}
        ]
    }
}

UPDATE

Updates the schema model with the provided values

{
    "Person": {
        "id": 1,
        "values": {
            "firstName": "Joseph",
            "lastName": "Momma"
        }
    }
}

DELETE

Deletes the schema model

{
    "Person": {
        "id": 1,
        "onDelete": {}
    }
}

The onDelete function will contain funtionality similar to the Django ORM, for example:

{
    "Person": {
        "id": 1,
        "onDelete": {
            "CASCADE": {
                "objectReferences": []
            },
            "PROTECT": {
                "objectReferences": []
            },
            "SET_NULL": {
                "objectReferences": []
            }
        }
    }
}

I am open to suggestions and contributors, feel free to critique my project, review it, fork it and build your own ideas on top of it !

Thank you !

More information can be found at RealmQL GitHub repository

Top comments (0)