GithubHelp home page GithubHelp logo

rccn's Introduction

This project was made purely for learning purposes.

RCCN

RCCN is a query language for key-value data structures, basically a clone of GraphQL.

Install

Clone this repository and generate the parser with ANTLR (the makefile is in the src directory):

make generate_parser

Then install it with pip from the base directory:

python3 -m pip install -e .

Now you can use the rccn package like this:

from antlr4 import InputStream
from rccn import rccn

def resolver():
    ...

input_stream = InputStream(input_text)
AST = rccn.parse(input_stream)
res = rccn.execute(AST, resolver)
print(res)

Examples

Check out an example of connecting to the PokemonAPI inside the examples/ directory.

The syntax of the language is basically GraphQL but commas are mandatory, therefore whitespace can be and is ignored.

Here's an example query to showcase the syntax :

type Query {
    ability(id: Int): Ability,
    pokemon(id: Int): Pokemon
}

type Ability {
    id: Int,
    name: String,
    is_main_series: Boolean
}

type Pokemon {
    id: Int,
    name: String,
    abilities: [Ability]
}

{
    pokemon (id: 2) {
        name,
        abilities {
            {
                name,
                is_main_series
            }
        }
    }
}

And here's the expected result in JSON for the above query:

{
  "pokemon": {
    "id": 2,
    "name": "ivysaur",
    "abilities": [
      {
        "name": "overgrow",
        "is_main_series": true
      },
      {
        "name": "chlorophyll",
        "is_main_series": true
      }
    ]
  }
}

Features

This language implements a small subset of the features GraphQL has, but nothing it doesn't have:

  • Type definitions
  • Selection sets with fields
  • Field parameters

For contrast, here's some features of GraphQL that RCCN /doesn't/ have:

  • Aliases
  • Fragments
  • Operation Name
  • Variables
  • Directives
  • Inline Fragments
  • Mutations
  • Subscriptions

rccn's People

Contributors

iuliana0109 avatar shunlog avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.