GithubHelp home page GithubHelp logo

slavikovbasa / hiku Goto Github PK

View Code? Open in Web Editor NEW

This project forked from evo-company/hiku

0.0 0.0 0.0 1.04 MB

Library to write servers for GraphQL-like query languages

Home Page: http://hiku.readthedocs.io

License: BSD 3-Clause "New" or "Revised" License

Shell 0.03% Python 99.71% Makefile 0.11% Dockerfile 0.16%

hiku's Introduction

Hiku

project documentation version tag license

Hiku is a library to implement Graph APIs. Essential GraphQL support included.

Installation

$ pip3 install hiku

Bug fixes and new features are frequently published via release candidates:

$ pip3 install --upgrade --pre hiku

Highlights

  • Not coupled to a single specific query language
  • Flexibility in result serialization, including binary formats
  • Natively uses normalized result representation, without data duplication
  • All concurrency models supported: coroutines, threads
  • Parallel query execution
  • No data under-fetching or over-fetching between client<->server and between server<->database
  • No N+1 problems by design
  • Introduces a concept of Two-Level Graph in order to decouple data-sources and business-logic

Quick example

Graph definition:

from hiku.graph import Graph, Root, Node, Field, Link
from hiku.types import String, Sequence, TypeRef

def characters_data(fields, ids):
    data = {
        1: {'name': 'James T. Kirk', 'species': 'Human'},
        2: {'name': 'Spock', 'species': 'Vulcan/Human'},
        3: {'name': 'Leonard McCoy', 'species': 'Human'},
    }
    return [[data[i][f.name] for f in fields] for i in ids]

def characters_link():
    return [1, 2, 3]

GRAPH = Graph([
    Node('Character', [
        Field('name', String, characters_data),
        Field('species', String, characters_data),
    ]),
    Root([
        Link('characters', Sequence[TypeRef['Character']],
             characters_link, requires=None),
    ]),
])

Query:

from hiku.engine import Engine
from hiku.builder import Q, build
from hiku.executors.sync import SyncExecutor

engine = Engine(SyncExecutor())

result = engine.execute(GRAPH, build([
    Q.characters[
        Q.name,
        Q.species,
    ],
]))

# use result in your code
for character in result.characters:
    print(character.name, '-', character.species)

Output:

James T. Kirk - Human
Spock - Vulcan/Human
Leonard McCoy - Human

Contributing

Use Tox in order to test and lint your changes.

hiku's People

Contributors

vmagamedov avatar kindermax avatar anxolerd avatar anti-social avatar popravich avatar brabadu avatar uvnikita 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.