Code Monkey home page Code Monkey logo

nadel's Introduction

Nadel: A distributed GraphQL engine

Nadel is a Kotlin library to combine several GraphQL services together. This is achieved by combining several underlying GraphQL services (schemas) into one schema (overall schema).

The main purpose of this library is to power a GraphQL gateway which serves as the entry point for executing requests across different services while presenting one GraphQL API.

Nadel GraphQL Gateway

Features

  • Compatible with Java codebases.
  • Directive based approach. Existing GraphQL tooling will continue to work.
  • Flexible GraphQL transform API. Modify fields and service call responses programmatically using the API.
  • Explicit overall schema design: if a schema member is not declared in the .nadel file it is not exposed.
  • Hydration: resolves references to other objects by calling other services.
  • Batching: hydration calls can be automatically batched with a configurable max batch size per call.
  • Field rename: fields can be given new names in the context of the exposed schema.
  • Type rename: types can be given new names in the context of the exposed schema.
  • Dynamic service resolution: ability to programmatically decide which service is called for a top level field.

Example

Let's assume we have two services: "Issues" and "Users". One has exposes issues and one has users. An Issue has a reference to its author User.

This is the schema for the Issues service:

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

And this is the Users service:

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

You can define a combined Nadel schema as follows.

# In Issue.nadel
type Query {
    issues: [Issue]
}
type Issue {
    id: ID
    author: User @hydrated(
        # This fetches users in batches
        field: "users"
        arguments: [{ name: "ids" value: "$source.authorId" }]
        inputIdentifiedBy: [{ sourceId: "authorId" resultId: "id" }]
    )
}

# In User.nadel
type Query {
    users(ids: [ID]): [User]
}
type User {
    id: ID
    name: String @renamed(from: "fullName")
}

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

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

The outside world does not know about the transformations applied by Nadel. It can simply query the data and Nadel will handle the rest e.g. under the hood Nadel will invoke Users for users data if Issue.author is requested for.

You can visit our test fixtures folder for many more examples.

Dev setup

In order to run the tests from EngineTests in IntelliJ you need to have the KoTest plugin installed.

Understanding Nadel.

nadel's People

Contributors

andimarek avatar andimarek-atlassian avatar artyomemelyanenko avatar bbakerman avatar danieltreacy avatar dondonz avatar dugenkui03 avatar dzhou-atlassian avatar faizan-siddiqui avatar felipe-gdr avatar gnawf avatar henryqdineen avatar johnliucn925 avatar llin2 avatar michaeloates avatar nikola-3 avatar rinconjc avatar russellyou avatar sajan-99 avatar sbarker2 avatar simeonleatherland avatar temaemelyan avatar tsroka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nadel's Issues

Difference between your DSL and graphqlSDL

Excuse me. I tried to find a document which descripts the difference between your DSL and graphqlSDL, but I did not find any doc. Is there a doc?Or there is no diference?

BTW, Thanks for your work! It's quite helpful!

Example and Tutorial

Would you mind giving an completed example or tutorial about how to implement / integrate this nadel project with GraphQL Java?

Some Questions about Nadel

Hello,
I have some questions, I hope you can give me answer on this.

  1. Is Nadel an GraphQL Gateway?
  2. Know you when the first Version will Release?
  3. Can I Nadel before first Version already use in Production, because it looks like Nadel is well developed.

Thanks for your help :)

rename innerQueris to underlying

$innerQueries.BazService.baz(barId: $source.barId, 
                                                                      id: $argument.bazId, 
                                                                       userId: $context.userId)

would become

$underlying.BazService.baz(barId: $source.barId, 
                                                                      id: $argument.bazId, 
                                                                       userId: $context.userId)

I think this is a way better semantic name... eg the underlying service called BazService

GraphQL downstream only?

Is it Nadel's intention to only combine GraphQL downstream services?

Can I somehow extend it with custom implementation? I have two use cases in mind.

  • Calling a REST downstream service to fulfill a GraphQL query.
  • Runtime switching between two GraphQL downstream services for ease of migration.

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.