Help us shape the future of Go! Take the 2026 Go Developer Survey

graphql

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GraphQLDateTime = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "DateTime",
	Description: "DateTime scalar type represents a date and time in ISO 8601 format",
	Serialize: func(value any) any {

		return value
	},
	ParseValue: func(value any) any {

		return value
	},
	ParseLiteral: func(valueAST ast.Value) any {

		if stringValue, ok := valueAST.(*ast.StringValue); ok {
			return stringValue.Value
		}
		return nil
	},
})

GraphQLDateTime is a custom scalar for DateTime fields

View Source
var GraphQLJSON = graphql.NewScalar(graphql.ScalarConfig{
	Name:        "JSON",
	Description: "JSON scalar type represents JSON data",
	Serialize: func(value any) any {
		return value
	},
	ParseValue: func(value any) any {
		return value
	},
	ParseLiteral: func(valueAST ast.Value) any {

		if stringValue, ok := valueAST.(*ast.StringValue); ok {
			return stringValue.Value
		}
		return nil
	},
})

GraphQLJSON is a custom scalar for JSON fields

View Source
var OrderByEnum = graphql.NewEnum(graphql.EnumConfig{
	Name:        "OrderBy",
	Description: "Order by direction",
	Values: graphql.EnumValueConfigMap{
		"ASC": &graphql.EnumValueConfig{
			Value: "ASC",
		},
		"DESC": &graphql.EnumValueConfig{
			Value: "DESC",
		},
	},
})

OrderByEnum creates an enum for ordering

Functions

func MapFieldTypeToGraphQL

func MapFieldTypeToGraphQL(fieldType schema.FieldType) graphql.Type

MapFieldTypeToGraphQL converts RediORM field types to GraphQL types

func WhereInputField

func WhereInputField(fieldType schema.FieldType) *graphql.InputObjectFieldConfig

WhereInputField creates a GraphQL input field for where conditions

Types

type Handler

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

Handler provides a generic HTTP handler for GraphQL requests

func NewHandler

func NewHandler(schema *graphql.Schema) *Handler

NewHandler creates a new GraphQL HTTP handler

func (*Handler) EnableGraphiQL

func (h *Handler) EnableGraphiQL() *Handler

EnableGraphiQL enables the GraphiQL interface

func (*Handler) EnablePlayground

func (h *Handler) EnablePlayground() *Handler

EnablePlayground enables the GraphQL Playground interface

func (*Handler) ServeGraphQL

func (h *Handler) ServeGraphQL(w http.ResponseWriter, r *http.Request)

ServeGraphQL handles GraphQL query execution

func (*Handler) ServeGraphiQL

func (h *Handler) ServeGraphiQL(w http.ResponseWriter, r *http.Request)

ServeGraphiQL serves the GraphiQL interface

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the http.Handler interface

func (*Handler) ServePlayground

func (h *Handler) ServePlayground(w http.ResponseWriter, r *http.Request)

ServePlayground serves the GraphQL Playground interface

func (*Handler) SetLogger added in v0.6.0

func (h *Handler) SetLogger(l logger.Logger) *Handler

SetLogger sets the logger for this handler

func (*Handler) SetPretty

func (h *Handler) SetPretty(pretty bool) *Handler

SetPretty enables or disables pretty printing of JSON responses

type SchemaGenerator

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

SchemaGenerator generates GraphQL schema from RediORM schemas

func NewSchemaGenerator

func NewSchemaGenerator(db types.Database, schemas map[string]*schema.Schema) *SchemaGenerator

NewSchemaGenerator creates a new schema generator

func (*SchemaGenerator) Generate

func (g *SchemaGenerator) Generate() (*graphql.Schema, error)

Generate creates the complete GraphQL schema

func (*SchemaGenerator) GetObjectTypes

func (g *SchemaGenerator) GetObjectTypes() map[string]*graphql.Object

GetObjectTypes returns the object types for debugging

type Server

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

Server represents a GraphQL server

func NewServer

func NewServer(config ServerConfig) (*Server, error)

NewServer creates a new GraphQL server

func (*Server) Handler added in v0.4.0

func (s *Server) Handler() http.Handler

Handler returns the GraphQL handler

func (*Server) Start

func (s *Server) Start() error

Start starts the GraphQL server

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the GraphQL server

type ServerConfig

type ServerConfig struct {
	DatabaseURI string
	SchemaPath  string
	Port        int
	Playground  bool
	CORS        bool
	LogLevel    string
}

ServerConfig contains configuration for the GraphQL server

Jump to

Keyboard shortcuts

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