dgraphql

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: Apache-2.0 Imports: 52 Imported by: 6

README

dfuse GraphQL API Services for Blockchains

reference License

This service is the API for querying blockchain data using GraphQL. It is part of dfuse.

Installation

See the different protocol-specific dfuse binaries at https://github.com/dfuse-io/dfuse#protocols

Current dgraphql implementations:

Usage

Connecting from command-line clients

  • Using https://github.com/Gavinpub/ws (which supports subprotocol negotiation)

    ws -s graphql-ws ws://127.0.0.1:8080/graphql

    {"id":"3","type":"connection_init","payload":{"Authorization":"Bearer ......"},"variables":null}}

    {"id":"3","type":"start","payload":{"query":"subscription{searchTransactionsForward(query: "status:executed", lowBlockNum:0, highBlockNum:0){ trace{ block { num } id }}}","variables":null}}

    {"id":"3","type":"start","payload":{"query":"subscription{searchTransactionsForward(query: "status:executed", lowBlockNum:0, highBlockNum:0){ trace{ block { num } id }}}","variables":null}}

  • Using curl:

    curl http://localhost:8080/graphql -XPOST -d '{"query": "{ searchTransactionsForward(limit: 10, query: "status:executed") { cursor } }"}' -H "Authorization: Bearer $DFUSE" | jq .

    curl http://localhost:8080/graphql -XPOST -d '{"query": "{ blockIDByTime(time: "2019-01-01T00:00:00Z") { time num } }"}' -H "Authorization: Bearer $DFUSE" | jq .

Contributing

Issues and PR in this repo related strictly to the core dgraphql API engine

Report any protocol-specific issues in their respective repositories

Please first refer to the general dfuse contribution guide, if you wish to contribute to this code base.

This codebase uses unit tests extensively, please write and run tests.

License

Apache 2.0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func AuthErrorHandler

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

func Errorf

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

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 EndpointServer

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

func NewEndpointServer

func NewEndpointServer(schema *graphql.Schema, authenticator authenticator.Authenticator) *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 OpencensusTracer

type OpencensusTracer struct {
}

func (*OpencensusTracer) TraceField

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

func (*OpencensusTracer) TraceQuery

func (t *OpencensusTracer) TraceQuery(
	ctx context.Context,
	queryString string,
	operationName string,
	variables map[string]interface{},
	varTypes map[string]*introspection.Type,
) (context.Context, gqtrace.TraceQueryFinishFunc)

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, cursorFactory func() proto.Message) (*Paginator, error)

func (*Paginator) Paginate

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

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 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,

) *Server

func (*Server) Launch

func (s *Server) Launch()

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