DEV Community

Kayne Ruse
Kayne Ruse

Posted on

Introducing simpleQL - my simple and easy to use graphQL clone made for fun!

curl -X POST https://krgamestudios.com/pokemon
    -H "Content-Type: text/plain"
    -d "Pokemon { name }"

https://github.com/ratstail91/simpleql

Allow me to present, a working (though incomplete) implementation of simpleQL!

The curl command above will send back an array of pokemon names as demonstration. In fact, each of the following fields are possible:

Pokemon {
    name
    height
    weight
    stats {
        hp
        attack
        defense
        specialAttack
        specialDefense
        speed
    }
    forms {
        name
        height
        weight
        stats {
            hp
            attack
            defense
            specialAttack
            specialDefense
            speed
        }
    }
}

Too much for you? That's fine, just use the match keyword!

Pokemon {
    match name "charizard"
    forms {
        name
        height
        weight
    }
}

How about matching compound sub-types?

Pokemon {
    name
    match forms {
        match name "charizard-mega-x"
    }
}

There are a few rules: every query must start by searching for a specific type, in this case Pokemon. Also, when listing a sub-type, at least one field must be listed.

Finally, for anyone implementing a handler - everything must return an array of objects - this may change in the future, but I'm still working on this.

I hope you like what I've done, and find it way easier to implement server-side than graphQL. Any questions, comments or critiques are welcome, particularly through the github issues page.

P.S. Yes, I know the name is taken, I'll be replacing it eventually.

Top comments (0)