Categorygithub.com/nautilus/gateway
modulepackage
0.4.0
Repository: https://github.com/nautilus/gateway.git
Documentation: pkg.go.dev

# README

nautilus/gateway CI Checks Coverage Status Go Report Card Go Reference

A library and standalone service that composes your GraphQL APIs into one endpoint.

For a guide to getting started read this post. For full documentation visit the gateway homepage.

Running the Executable

The simplest way to run a gateway is to download an executable for your operating system from the latest release on GitHub and then run it directly on your machine:

$ ./gateway start --port 4000 --services http://localhost:3000,http://localhost:3001

Note: Instead of ./gateway, use the file path to the release you downloaded. macOS users should use the darwin release file.

For more information on possible arguments to pass the executable, run ./gateway --help.

Build from source

Alternatively, install it with the go command to your Go bin and run it:

$ go install github.com/nautilus/gateway/cmd/gateway@latest
$ gateway start --port 4000 --services http://localhost:3000,http://localhost:3001

This will start a server on port 4000 that wraps over the services running at http://localhost:3000 and http://localhost:3001.

For more information on possible arguments to pass the executable, run gateway --help.

Versioning

This project is built as a go module and follows the practices outlined in the spec. Please consider all APIs experimental and subject to change until v1 has been released at which point semantic versioning will be strictly followed. Before then, minor version bumps denote an API breaking change.

Currently supports Go Modules using Go 1.16 and above.

# Functions

New instantiates a new schema with the required stuffs.
NewAutomaticQueryPlanCache returns a fresh instance of.
WithAutomaticQueryPlanCache enables the "automatic persisted query" technique.
WithExecutor returns an Option that sets the executor of the gateway.
No description provided by the author
WithLogger returns an Option that sets the logger of the gateway.
WithMerger returns an Option that sets the merger of the gateway.
WithMiddlewares returns an Option that adds middlewares to the gateway.
WithNoQueryPlanCache is the default option and disables any persisted query behavior.
WithPlanner returns an Option that sets the planner of the gateway.
WithQueryerFactory returns an Option that changes the queryer used by the planner when generating plans that interact with remote services.
WithQueryFields returns an Option that adds the given query fields to the gateway.
WithQueryPlanCache sets the query plan cache that the gateway will use.

# Constants

MessageMissingCachedQuery is the string that the server sends when the user assumes that the server knows about a caches query plan.

# Structs

AutomaticQueryPlanCache is a QueryPlanCache that will use the hash if it points to a known query plan, otherwise it will compute the plan and save it for later, to be referenced by the designated hash.
DefaultLogger handles the logging in the gateway library.
ErrExecutor always returnes the internal error.
ExecutionContext is a well-type alternative to context.Context and provides the context for a particular execution.
Gateway is the top level entry for interacting with a gateway.
HTTPOperation is the incoming payload when sending POST requests to the gateway.
MinQueriesPlanner does the most basic level of query planning.
MockErrPlanner always returns the provided error.
MockExecutor always returns a success with the provided value.
MockPlanner always returns the provided list of plans.
NoQueryPlanCache will always compute the plan for a query, regardless of the value passed as `hash`.
ParallelExecutor executes the given query plan by starting at the root of the plan and walking down the path stitching the results together.
No description provided by the author
Planner is meant to be embedded in other QueryPlanners to share configuration.
PlanningContext is the input struct to the Plan method.
PlaygroundConfig contains configuration for rendering a playground UI with a few, critical settings.
PlaygroundSettings contains settings for setting up a playground UI.
QueryField is a hook to add gateway-level fields to a gateway.
QueryPlan is the full plan to resolve a particular query.
QueryPlanStep represents a step in the plan required to fulfill a query.
RequestContext holds all of the information required to satisfy the user's query.

# Interfaces

ExecutionMiddleware are things that interject in the execution process.
Executor is responsible for executing a query plan against the remote schemas and returning the result.
Logger logs messages.
Merger is an interface for structs that are capable of taking a list of schemas and returning something that resembles a "merge" of those schemas.
Middleware are things that can modify a gateway normal execution.
PlannerWithLocationFactory is an interface for planners with configurable location priorities.
PlannerWithQueryerFactory is an interface for planners with configurable queryer factories.
QueryPlanCache decides when to compute a plan.
QueryPlanner is responsible for taking a string with a graphql query and returns the steps to fulfill it.

# Type aliases

ExecutorFunc wraps a function to be used as an executor.
FieldURLMap holds the intformation for retrieving the valid locations one can find the value for the field.
LoggerFields is a wrapper over a map of key,value pairs to associate with the log.
MergerFunc is a wrapper of a function of the same signature as Merger.Merge.
MiddlewareList is a list of Middlewares.
Option is a function to be passed to New that configures the resulting schema.
QueryerFactory is a function that returns the queryer to use depending on the context.
QueryPlanList is a list of plans which can be indexed by operation name.
RequestMiddleware is a middleware that can modify outbound requests to services.
ResponseMiddleware is a middleware that can modify the response before it is serialized and sent to the user.
Set is a set.