gqlserver

package module
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 28 Imported by: 0

README

gqlserver

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = ServerConfig{
	IgnoreWebSocketUpgradeCheck: false,
	ComplexityLimit:             300,
	ApqCache:                    lru.New(100),
	QueryCache:                  lru.New(1000),
	GraphqlPath:                 "/graphql",
	PlaygroundPath:              "/play",
	PlaygroundEnabled:           false,
	IntrospectionEnabled:        false,
	Port:                        3000,
	LogLevel:                    logrus.InfoLevel,
	ServiceName:                 "unnamed",
	Environment:                 Dev,
	IDHashSalt:                  "notasecret",
	IDHashMinLength:             7,
	NewRelic: NewRelicConfig{
		Enabled:  false,
		EuRegion: false,
		GraphqlExtension: nrextension.Config{
			NoticeErrorOnResolverPanic: true,
			NoticeErrorOnGraphQLError:  true,
		},
	},
	Auth: auth.AuthConfig{
		FirebaseEnabled: false,
	},
	Cors: CorsConfig{
		Enabled:      true,
		AllowOrigins: []string{"http://localhost:3000"},
	},
}

Functions

func MarshalID

func MarshalID(id hide.ID) graphql.Marshaler

MarshalID implements marshalling for IDs

func ParsedSchema added in v0.0.6

func ParsedSchema() string

func UnmarshalID

func UnmarshalID(v interface{}) (hide.ID, error)

UnmarshalID implements reverse marshalling for IDs from strings

Types

type CorsConfig added in v0.0.19

type CorsConfig struct {
	// Enable CORS
	Enabled bool `env:"CORS_ENABLED"`

	AllowOrigins []string `env:"CORS_ALLOW_ORIGINS"`
}

type Environment

type Environment string
const (
	Dev     Environment = "dev"
	Test    Environment = "test"
	Staging Environment = "staging"
	Prod    Environment = "prod"
)

type LogrusNewrelicHook added in v0.0.30

type LogrusNewrelicHook struct {
	// contains filtered or unexported fields
}

func NewLogrusNewrelicHook added in v0.0.30

func NewLogrusNewrelicHook(nrApp *newrelic.Application) *LogrusNewrelicHook

func (*LogrusNewrelicHook) Fire added in v0.0.30

func (h *LogrusNewrelicHook) Fire(entry *logrus.Entry) error

func (*LogrusNewrelicHook) Levels added in v0.0.30

func (h *LogrusNewrelicHook) Levels() []logrus.Level

type NewRelicConfig added in v0.0.9

type NewRelicConfig struct {
	// Enable New Relic integration
	Enabled bool `env:"NEW_RELIC_ENABLED"`

	// License key for New Relic integration
	LicenseKey string `env:"NEW_RELIC_LICENSE_KEY"`

	// Whether or not the New Relic account is in the EU region
	EuRegion bool `env:"NEW_RELIC_EU_REGION"`

	GraphqlExtension nrextension.Config
}

type Server

type Server struct {
	Logger *logrus.Entry
	// contains filtered or unexported fields
}

func NewServer

func NewServer(es graphql.ExecutableSchema, cfg ServerConfig) Server

func (*Server) RegisterExtension added in v0.0.5

func (s *Server) RegisterExtension(extension graphql.HandlerExtension)

func (*Server) RegisterMiddleware

func (s *Server) RegisterMiddleware(middleware ...gin.HandlerFunc)

func (*Server) Run

func (s *Server) Run()

type ServerConfig

type ServerConfig struct {
	//
	IgnoreWebSocketUpgradeCheck bool `env:"IGNORE_WEB_SOCKET_UPGRADE_CHECK"`

	// ComplexityLimit of 0 means no limit
	ComplexityLimit int `env:"COMPLEXITY_LIMIT"`

	// ApqCache for automatic persisted query hashes
	ApqCache graphql.Cache

	// QueryCache
	QueryCache graphql.Cache

	// Endpoint for the GraphQL handler
	GraphqlPath string `env:"GRAPHQL_PATH"`

	// Endpoint for the GraphQL playground handler
	PlaygroundPath string `env:"PLAYGROUND_PATH"`

	// Whether or not the playground is enabled
	PlaygroundEnabled bool `env:"PLAYGROUND_ENABLED"`

	// Whether or not schema introspection is enabled
	// Introspection is enabled when Playground is enabled
	IntrospectionEnabled bool `env:"INTROSPECTION_ENABLED"`

	// Port to bind HTTP server to
	Port int `env:"PORT"`

	// Logger minimum level
	LogLevel logrus.Level `env:"LOG_LEVEL"`

	// Name of this service to report in logs
	ServiceName string `env:"SERVICE_NAME"`

	// Environment of this service to report in logs
	Environment Environment `env:"ENVIRONMENT"`

	// Salt used to generated ID hashes
	IDHashSalt string `env:"ID_HASH_SALT"`

	// Minimum length of ID hashes
	IDHashMinLength int `env:"ID_HASH_MIN_LENGTH"`

	// New Relic Configuration
	NewRelic NewRelicConfig

	// Auth Configuration
	Auth auth.AuthConfig

	// CORS Configuration
	Cors CorsConfig
}

func NewConfigFromEnvironment added in v0.0.12

func NewConfigFromEnvironment() ServerConfig

Directories

Path Synopsis
graphql

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL