All Projects → atlassian-labs → nadel

atlassian-labs / nadel

Licence: Apache-2.0 License
A GraphQL DSL and execution engine for distributed schemas

Programming Languages

kotlin
9241 projects
groovy
2714 projects
java
68154 projects - #9 most used programming language

Labels

Nadel: A distributed GraphQL engine

Nadel is a Java 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

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 required 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 {
    users(ids: [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.users(ids: $source.authorIds) object identified by id, batch size 10
    }
}

service Users {
    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
}

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

Dev setup

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].