Code Monkey home page Code Monkey logo

nadel's Introduction

WARNING: STILL WIP AND NOT RELEASED YET

Nadel: A GraphQL DSL and execution engine for distributed schemas

This is a Java library to combine several graphql services together.

This is achieved by declaring the services, which should be combined, in a DSL which is build on top of the GraphQL SDL (Schema Definition Language).

While this library is in Java, the underlying services only need to provide a standard GraphQL API and no Java Code is needed to combine services together. It is all done declarative as part of the DSL.

Example:

Lets assume we have two Services: "Issues" and "Users". One has Issues and one has Users. An Issue has a reference to its authors.

This is the schema for the Issues service:

type Query {
    issues: [Issue]
}
type Issue {
    id: ID
    authorIds: [ID]
}

And this is the Users service:

type Query {
    usersById(id: [ID]): [User]
}
type User {
    id: ID
    fullName: String
}

This is how you would combine these two services together with Nadel while also renaming a field at the same time.

service Issues {
    type Query {
        issues: [Issue]
    }
    type Issue {
        id: ID
        authors: [User] => hydrated from Users.usersById(id: $source.authorIds) batch size 10
    }
}

service Users {
    type Query {
        usersById(id: [ID]): [User]
    }
    type User {
        id: ID
        name: String => renamed from $source.fullName
    }
}

The result is a new GraphQL API which combines the two services in one and has the following schema:

type Query {
    issues: [Issue]
    usersById(id: [ID]): [User]
}       
type Issue {
    id: ID
    authors: [User]
}
type User {
    id: ID
    name: String
}

Features

  • Explicit overall schema design: every field for the overall schema needs to be declared in the Nadel DSL. If it is not declared it will not be exposed
  • Hydration: resolving referencing to other objects by calling another service
  • Field rename: renaming field from the underlying schema to a new name in the overall schema
  • Type rename: renaming a type from the underlying schema to a new name in the overall schema
  • Batching: Hydration calls are automatically batched with a configurable max batch size per call

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.