genqlient is a Go library to easily generate type-safe code to query a GraphQL API. It takes advantage of the fact that both GraphQL and Go are typed languages to ensure at compile-time that your code is making a valid GraphQL query and using the result correctly, all with a minimum of boilerplate.
genqlient provides:
interface{}
.graphql-go-tools implements all basic blocks for building GraphQL Servers, Gateways and Proxy Servers. From lexing, parsing, validation, normalization, all the way up to query planning and execution.
It can also be understood as a GraphQL Compiler, with the ability to add your own backends. Just by implementing a few interfaces, you’re able to teach the compiler how to talk GraphQL to any backend.
The following backends are already implemented: GraphQL, with support for Apollo Federation / Supergraph. Databases: PostgreSQL, MySQL, SQLite, CockroachDB, MongoDB, SQLServer, OpenAPI / REST and Kafka.
To get a sense on how to implement a new backend, check out the Static Data Source, as it’s the simplest one.
It’s used in production by many enterprises for multiple years now, battle tested and actively maintained.
The purpose of Eggql is to make it as simple as possible to create a GraphQL server. You don’t need to create GraphQL schema (though you can view the schema that is created if interested). It is currently in beta release but is a complete implementation of a GraphQL server apart from subscriptions.
Just to be clear it supports all of these GraphQL features: arguments (including defaults), objects/lists/enums/input/interface/union types, aliases, fragments, variables, directives, mutations, inline fragments, descriptions, introspection and custom scalars.
Tests (jMeter) show that it is as fast or faster than other Go implementations for simple queries. We’re working on enhancements for performance including caching, data-loader, complexity-limits, etc.
To run an eggql
hello world server just build and run this Go program:
package main
import "github.com/andrewwphillips/eggql"
func main() {
http.Handle("/graphql", eggql.New(struct{ Message string }{Message: "hello, world"}))
http.ListenAndServe(":80", nil)
}
This creates a root Query object with a single message
field. To test it send a query with curl:
$ curl -XPOST -d '{"query": "{ message }"}' localhost:80/graphql
and you will get this response:
{
"data": {
"message": "hello, world"
}
}