dgraphql

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: Apache-2.0 Imports: 55 Imported by: 0

README

中数文dgraphql

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IdentityCursorDecoder = &identityCursorDecoder{}
View Source
var SchemaRegistry = map[string][]byte{}

Functions

func AuthErrorHandler

func AuthErrorHandler(w http.ResponseWriter, ctx context.Context, err error)

func CompressionMiddleware

func CompressionMiddleware(next http.Handler) http.Handler

func Errorf

func Errorf(ctx context.Context, format string, args ...interface{}) *errors.QueryError

func IsDeadlineExceededError

func IsDeadlineExceededError(err error) bool

IsDeadlineExceededError checks wheter error is `context.DeadlineExceeded` or a gRPC RPC error for which the code is `codes.DeadlineExceeded`.

func LoggingMiddleware

func LoggingMiddleware(next http.Handler) http.Handler

func MergeSchemas

func MergeSchemas(first string, second string) string

MergeSchemas is a poor man way of merging some specific GraphQL types together to form a single schemas.

The algorithm simply reads the schema and look for the pattern `type Query {(.*)}` and `type Subscription {(.*)}`, collecting them along the way and removing from the actual buffer.

Once the full schema has been processed, we simply append a `type Query { ... }` node with the content (regexp sub-match) of the various collected queries in the first pass, same for `Subscription`.

This creates a final `Query` and `Subscription` type of the collected merged elements.

**Important** This is regexp based, so the current drawback of this technique

is that the inner sub-match content must not contain a `{ }` pair.
This is easy to achieve and maintain.

func MustProtoToOpaqueCursor

func MustProtoToOpaqueCursor(entity proto.Message, entityTag string) string

func NewCORSMiddleware

func NewCORSMiddleware() mux.MiddlewareFunc

func RegisterSchema

func RegisterSchema(schemaPrefix, schemaName string, schemaData []byte)

func Status

func Status(ctx context.Context, code codes.Code, message string) *errors.QueryError

func UnmarshalCursorProto

func UnmarshalCursorProto(opaqued string, entity proto.Message) error

func UnwrapError

func UnwrapError(ctx context.Context, err error) *errors.QueryError

Types

type CursorDecoder added in v0.3.0

type CursorDecoder interface {
	Decode(string) (string, error)
}

type EndpointServer

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

func NewEndpointServer

func NewEndpointServer(schema *graphql.Schema, authenticator authenticator.Authenticator, shut *shutter.Shutter) *EndpointServer

func (*EndpointServer) Execute

type Keyable

type Keyable interface {
	Key() string
}

type MultiRouterClient

type MultiRouterClient struct {
	Toggle *atomic.Bool
	// contains filtered or unexported fields
}

func NewMultiRouterClient

func NewMultiRouterClient(v1Client pbsearch.RouterClient, v2Client pbsearch.RouterClient) *MultiRouterClient

func (*MultiRouterClient) StreamMatches

type OpaqueProtoCursorDecoder added in v0.3.0

type OpaqueProtoCursorDecoder struct {
	EntityFactory func() proto.Message
}

func NewOpaqueProtoCursorDecoder added in v0.3.0

func NewOpaqueProtoCursorDecoder(factory func() proto.Message) OpaqueProtoCursorDecoder

func (OpaqueProtoCursorDecoder) Decode added in v0.3.0

func (d OpaqueProtoCursorDecoder) Decode(input string) (string, error)

type Paginator

type Paginator struct {
	HasPreviousPage bool
	HasNextPage     bool
	// contains filtered or unexported fields
}

func NewPaginator

func NewPaginator(firstReq, lastReq *types.Uint32, before, after *string, limit uint32, cursorDecoder CursorDecoder) (*Paginator, error)

func (*Paginator) Paginate

func (p *Paginator) Paginate(results Pagineable) Pagineable

Paginate takes a full slice of results and returns a paginated view of them, for example the elements after a given key or the elements in-between an after and before key.

type Pagineable

type Pagineable interface {
	Length() int
	IsEqual(index int, key string) bool
	Append(slice Pagineable, index int) Pagineable
}

type PagineableStrings

type PagineableStrings []string

func (PagineableStrings) Append

func (p PagineableStrings) Append(slice Pagineable, index int) Pagineable

func (PagineableStrings) IsEqual

func (p PagineableStrings) IsEqual(index int, key string) bool

func (PagineableStrings) Length

func (p PagineableStrings) Length() int

type SchemaFactory

type SchemaFactory interface {
	Schemas() (*Schemas, error)
}

type SchemaSelector

type SchemaSelector interface {
	SchemaID() schemaID
	String() string
}

func WithAlpha

func WithAlpha() SchemaSelector

type Schemas

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

func NewSchemas

func NewSchemas(resolver interface{}) (*Schemas, error)

func (*Schemas) GetSchema

func (s *Schemas) GetSchema(selectors ...SchemaSelector) *graphql.Schema

type Server

type Server struct {
	*shutter.Shutter

	DataIntegrityProofSecret string
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	grpcListenAddr string,
	httpListenAddr string,
	protocol string,
	networkID string,
	overrideTraceID bool,
	authenticator authenticator.Authenticator,
	metering dmetering.Metering,
	schemas *Schemas,
	dataIntegrityProofSecret string,
	jwtIssuerURL string,
	apiKey string,
	predfinedGraphqlExamples []*static.GraphqlExample,

) *Server

func (*Server) Launch

func (s *Server) Launch()

type Tracer added in v0.3.0

type Tracer struct {
}

func (*Tracer) TraceField added in v0.3.0

func (t *Tracer) TraceField(
	ctx context.Context,
	label, typeName, fieldName string,
	trivial bool,
	args map[string]interface{},
) (context.Context, gqtrace.TraceFieldFinishFunc)

func (*Tracer) TraceMutation added in v0.3.0

func (*Tracer) TraceQuery added in v0.3.0

func (*Tracer) TraceRequest added in v0.3.0

func (t *Tracer) TraceRequest(
	ctx context.Context,
	queryString string,
	opType string,
	operationName string,
	variables map[string]interface{},
	varTypes map[string]*introspection.Type,
) (context.Context, gqtrace.TraceRequestFinishFunc)

func (*Tracer) TraceSubscription added in v0.3.0

Directories

Path Synopsis
app
Code generated by rice embed-go; DO NOT EDIT.
Code generated by rice embed-go; DO NOT EDIT.

Jump to

Keyboard shortcuts

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