Skip to content
This repository has been archived by the owner on Sep 13, 2022. It is now read-only.

graphql-java/batched-graphql-execution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Batched GraphQL execution

Note: This is not an open source project. It is not licensed under an open source compatible license at this moment.

This is a custom execution engine for GraphQL Java which is optimized for batching to avoid the N+1 problem.

This is an alternative approach to using batched data loading

It is fully reactive using Reactor.

Overview

The N+1 problem occurs when one Object can lead to N queries per child. For example:

type Query {
    people: [Person]
}
type Person {
    id: ID
    friends: [Person]
}

A query like this {people{friends{name}} needs to load the friends for each person. If we have 5 people and each person has 5 friends we need to load 25 persons overall.

Instead of making 25 calls (to a DB or another service) we would like to make 1 call which loads all 25 people at once.

In order to make this as easy as possible this engine provides a BatchedDataFetcher:

public interface BatchedDataFetcher {
    Mono<BatchedDataFetcherResult> get(BatchedDataFetcherEnvironment environment);
}

A BatchedDataFetcherEnvironment contains the list of fields and sources which should be loaded:

    List<Object> sources;
    List<NormalizedField> normalizedFields;
    List<ExecutionPath> executionPaths;

About

Batched GraphQL execution engine

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published