DEV Community

Kayne Ruse
Kayne Ruse

Posted on

1 3

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.

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay