• Stars
    star
    690
  • Rank 65,522 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 6 years ago
  • Updated 2 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GraphQL Router / API Gateway framework written in Golang, focussing on correctness, extensibility, and high-performance. Supports Federation v1 & v2, Subscriptions & more.

GoDoc CI

graphql-go-tools

Apollo Federation Gateway Replacement

This library can be used as a replacement for the Apollo Federation Gateway. It implements the Apollo Federation Specification.

In addition to the scope of other implementations, this one supports Subscriptions!

Check out the Demo.

Overview

This repository implements low level building blocks to write graphql services in Go.

With this library you could build tools like:

  • proxies
  • caches
  • server/client implementations
  • a WAF
  • be creative! =)

Currently implemented:

  • GraphQL AST as of https://graphql.github.io/graphql-spec/June2018
  • Token lexing
  • AST parsing: parse bytes/string into AST
  • AST printing: print an AST to an io.Writer
    • supports indentation
  • AST validation:
    • all rules from the spec implemented
  • AST visitor:
    • simple visitor: fastest implementation, without field type definition information
    • visitor: a bit more overhead but has field type definitions and other quirks
  • AST normalization
    • remove unnecessary include/skip directives
    • field deduplication
    • field selection merging
    • fragment definition removal
    • fragment spread inlining
    • inline fragment merging
    • remove self aliasing
    • type extension merging
    • remove type extensions
  • Introspection: transforms a graphql schema into a resolvable Data Source
  • AST execution
    • query planning: turns a Query AST into a cacheable execution plan
      • supported DataSources:
        • GraphQL (multiple GraphQL services can be combined)
        • static (static embedded data)
        • REST
    • query execution: takes a context object and executes an execution plan
  • Middleware:
    • Operation Complexity: Calculates the complexity of an operation based on the GitHub algorithm
  • OperationReport: Makes it easy to collect errors during all phases of a request and enables easy error printing according to the GraphQL spec
  • Playground: Easy hosting of GraphQL Playground (no external dependencies, simple middleware)
  • Import Statements: combine multiple GraphQL files into one single schema using #import statements
  • Implements the Apollo Federation Specification: Replacement for Apollo Federation Gateway

Go version Info

This repos uses go modules so make sure to use the latest version of Go.

Docs

https://godoc.org/github.com/wundergraph/graphql-go-tools

Usage

Look into the docs. Other than that, tests definitely help understanding this library.

Testing

make test

Linting

make lint

Performance

Most hot path operations have 0 allocations. You should expect this library to exceed all alternatives in terms of performance. I've compared my implementation vs. others but why trust my numbers? Feel free to add comparisons via PR.

Benchmarks

Parse Kitchen Sink (1020 chars, example from Facebook):

pkg: github.com/wundergraph/graphql-go-tools/pkg/astparser
BenchmarkKitchenSink 	  189426	      5652 ns/op	       0 B/op	       0 allocs/op
BenchmarkKitchenSink 	  198253	      5526 ns/op	       0 B/op	       0 allocs/op
BenchmarkKitchenSink 	  199924	      5553 ns/op	       0 B/op	       0 allocs/op
BenchmarkKitchenSink 	  212695	      5804 ns/op	       0 B/op	       0 allocs/op

CPU and Memory consumption for lexing, parsing as well as most other operations is neglectable, even for larger queries.

Contributors

  • Jens Neuse (Project Lead & Active Maintainer)
  • Mantas Vidutis
    • Contributions to the http proxy & the Context Middleware
  • Jonas Bergner
    • Contributions to the initial version of the parser, contributions to the tests
    • Implemented Type Extension merging #108
  • Patric Vormstein (Active Maintainer)
    • Fixed lexer on windows #92
    • Author of the graphql package to simplify the usage of the library
    • Refactored the http package to simplify usage with http servers
    • Author of the starwars package to enhance testing
  • Sergey Petrunin (Active Maintainer)
    • Helped cleaning up the API of the pipeline package #166
    • Refactored the ast package into multiple files
    • Author of the introspection converter (introspection JSON -> AST)
    • Fixed various bugs in the parser & visitor & printer
    • Refactored and enhanced the astimport package
  • Vasyl Domanchuk
    • Implemented the logic to generate a federation configuration
    • Added federation example

Contributions

Feel free to file an issue in case of bugs. We're open to your ideas to enhance the repository.

You are open to contribute via PR's. Please open an issue to discuss your idea before implementing it so we can have a discussion. Make sure to comply with the linting rules. You must not add untested code.

More Repositories

1

wundergraph

WunderGraph is a Backend for Frontend Framework to optimize frontend, fullstack and backend developer workflows through API Composition.
TypeScript
2,268
star
2

wunderbase

Serverless GraphQL Database built on top of Firecracker, SQLite and Prisma
Go
490
star
3

open-previews

Open source preview comments
TypeScript
120
star
4

hopper

Modern GraphQL IDE, similar to GraphiQL and GraphQL Playground. Based on Monaco Editor (vscode).
TypeScript
65
star
5

wundergraph-demo

This Repository demonstrates how to combine 7 APIs (4 Apollo Federation SubGraphs, 1 REST, 1 standalone GraphQL, 1 Mock) into one unified GraphQL API which is then securely exposed as a JSON API to a NextJS Frontend.
TypeScript
58
star
6

nextjs-typescript-postgresql-graphql-realtime-chat

WunderGraph Realtime Chat Example using NextJS, TypeScript, PostgreSQL, GraphQL
TypeScript
51
star
7

federation-benchmarks

Comparison of a different federation gateways, e.g. supergraphs implementations
Go
17
star
8

docker

Build your custom docker image for your WunderGraph application
TypeScript
14
star
9

cloud-starter

A simple starter application that that can be deployed on WunderGraph Cloud
TypeScript
9
star
10

kubernetes-deployment

Run WunderGraph on any Kubernetes cluster
TypeScript
7
star
11

Hypermedia-GraphQL

Hypermedia GraphQL RFC
6
star
12

cosmo-federation-demos

WunderGraph Cosmo Federation demonstrations in TypeScript or Go
Shell
6
star
13

polyglot-persistence-postgresql-mysql-graphql

This repo demonstrates how to achieve polyglot persistence for PostgreSQL & MySQL using GraphQL as the layer of abstraction.
TypeScript
5
star
14

cloud-starter-turbo

Use Turborepo to speed up builds in monorepos.
TypeScript
3
star
15

cloud-demo

A demo for cloud containing 2 apps in a monorepo.
TypeScript
3
star
16

graphql-federation-monolith-to-microservices-workshop-nestjs

This is a workshop that teaches how to leverage GraphQL Federation & WunderGraph Cosmo to decompose a monolith into microservices.
TypeScript
3
star
17

nextjs-graphql-client-comparison

TypeScript
2
star
18

cloud-multi-projects-demo

A demo about how to manage multiple WunderGraph Projects in a single repository (monorepo).
TypeScript
2
star
19

wundergraph-protobuf

TypeScript
1
star
20

rust-client

Rust client for WunderGraph applications
Rust
1
star
21

terraform-provider-cosmo

Go
1
star
22

.github

Holds org-wide configuration files.
1
star
23

apollo-federation-compatibility-demo

JavaScript
1
star