schema

package
v25.0.0-custom-qt-impr... Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrExpectedScalar = "An object type was returned, but GraphQL was expecting a scalar. " +
		"This indicates an internal error - " +
		"probably a mismatch between the GraphQL and Dgraph/remote schemas. " +
		"The value was resolved as null (which may trigger GraphQL error propagation) " +
		"and as much other data as possible returned."

	ErrExpectedSingleItem = "A list was returned, but GraphQL was expecting just one item. " +
		"This indicates an internal error - " +
		"probably a mismatch between the GraphQL and Dgraph/remote schemas. " +
		"The value was resolved as null (which may trigger GraphQL error propagation) " +
		"and as much other data as possible returned."

	ErrExpectedList = "An item was returned, but GraphQL was expecting a list of items. " +
		"This indicates an internal error - " +
		"probably a mismatch between the GraphQL and Dgraph/remote schemas. " +
		"The value was resolved as null (which may trigger GraphQL error propagation) " +
		"and as much other data as possible returned."

	ErrExpectedNonNull = "Non-nullable field '%s' (type %s) was not present in result from Dgraph.  " +
		"GraphQL error propagation triggered."
)
View Source
const (
	CacheControlHeader = "Cache-Control"

	BATCH  = "BATCH"
	SINGLE = "SINGLE"

	// geo type names and fields
	Point        = "Point"
	Polygon      = "Polygon"
	MultiPolygon = "MultiPolygon"
	Latitude     = "latitude"
	Longitude    = "longitude"
	Points       = "points"
	Coordinates  = "coordinates"
	Polygons     = "polygons"

	NumUid = "numUids"
	Msg    = "msg"

	Typename = "__typename"
)
View Source
const (
	GetQuery                      QueryType    = "get"
	SimilarByIdQuery              QueryType    = "querySimilarById"
	SimilarByEmbeddingQuery       QueryType    = "querySimilarByEmbedding"
	FilterQuery                   QueryType    = "query"
	AggregateQuery                QueryType    = "aggregate"
	SchemaQuery                   QueryType    = "schema"
	EntitiesQuery                 QueryType    = "entities"
	PasswordQuery                 QueryType    = "checkPassword"
	HTTPQuery                     QueryType    = "http"
	DQLQuery                      QueryType    = "dql"
	NotSupportedQuery             QueryType    = "notsupported"
	AddMutation                   MutationType = "add"
	UpdateMutation                MutationType = "update"
	DeleteMutation                MutationType = "delete"
	HTTPMutation                  MutationType = "http"
	NotSupportedMutation          MutationType = "notsupported"
	IDType                                     = "ID"
	InputArgName                               = "input"
	UpsertArgName                              = "upsert"
	FilterArgName                              = "filter"
	SimilarByArgName                           = "by"
	SimilarTopKArgName                         = "topK"
	SimilarVectorArgName                       = "vector"
	EmbeddingEnumSuffix                        = "Embedding"
	SimilarQueryPrefix                         = "querySimilar"
	SimilarByIdQuerySuffix                     = "ById"
	SimilarByEmbeddingQuerySuffix              = "ByEmbedding"
	SimilarQueryResultTypeSuffix               = "WithDistance"
	SimilarQueryDistanceFieldName              = "vector_distance"
	SimilarSearchMetricEuclidean               = "euclidean"
	SimilarSearchMetricDotProduct              = "dotproduct"
	SimilarSearchMetricCosine                  = "cosine"
)

Query/Mutation types and arg names

View Source
const (
	RBACQueryPrefix = "{"
)

Variables

View Source
var (
	// JsonNull are the bytes to represent null in JSON.
	JsonNull = []byte("null")
	// JsonEmptyList are the bytes to represent an empty list in JSON.
	JsonEmptyList = []byte("[]")
)

Functions

func AppendGQLErrs

func AppendGQLErrs(err1, err2 error) error

AppendGQLErrs builds a list of GraphQL errors from err1 and err2, if both are nil, the result is nil.

func AsGQLErrors

func AsGQLErrors(err error) x.GqlErrorList

AsGQLErrors formats an error as a list of GraphQL errors. A []*x.GqlError (x.GqlErrorList) gets returned as is, an x.GqlError gets returned as a one item list, and all other errors get printed into a x.GqlError . A nil input results in nil output.

func CamelCase

func CamelCase(x string) string

func CompleteObject

func CompleteObject(
	path []interface{},
	fields []Field,
	res map[string]interface{}) ([]byte, x.GqlErrorList)

CompleteObject builds a json GraphQL result object for the current query level. It returns a bracketed json object like { f1:..., f2:..., ... }. At present, it is only used for building custom results by:

  • Admin Server
  • @custom(http: {...}) query/mutation
  • @custom(dql: ...) queries

fields are all the fields from this bracketed level in the GraphQL query, e.g:

{
  name
  dob
  friends {...}
}

If it's the top level of a query then it'll be the top level query name.

typ is the expected type matching those fields, e.g. above that'd be something like the `Person` type that has fields name, dob and friends.

res is the results map from Dgraph for this level of the query. This map needn't contain values for all the requested fields, e.g. if there's no corresponding values in the store or if the query contained a filter that excluded a value. So res might be the map : name->"A Name", friends -> []interface{}

CompleteObject fills out this result putting in null for any missing values (dob above) and applying GraphQL error propagation for any null fields that the schema says can't be null.

Example:

if the map is name->"A Name", friends -> []interface{}

and "dob" is nullable then the result should be json object {"name": "A Name", "dob": null, "friends": ABC} where ABC is the result of applying CompleteValue to res["friends"]

if "dob" were non-nullable (maybe it's type is DateTime!), then the result is nil and the error propagates to the enclosing level.

func CompleteValue

func CompleteValue(
	path []interface{},
	field Field,
	val interface{}) ([]byte, x.GqlErrorList)

CompleteValue applies the value completion algorithm to a single value, which could turn out to be a list or object or scalar value.

func GQLWrapLocationf

func GQLWrapLocationf(err error, loc x.Location, format string, args ...interface{}) error

GQLWrapLocationf wraps an error as a GraphQL error and includes location information in the GraphQL error.

func GQLWrapf

func GQLWrapf(err error, format string, args ...interface{}) error

GQLWrapf takes an existing error and wraps it as a GraphQL error. If err is already a GraphQL error, any location information is kept in the new error. If err is nil, GQLWrapf returns nil.

Wrapping GraphQL errors like this allows us to bubble errors up the stack and add context, location and path info to them as we go.

func GetBodyForLambda

func GetBodyForLambda(ctx context.Context, field Field, parents,
	args interface{}) map[string]interface{}

func Introspect

func Introspect(q Query) (json.RawMessage, error)

Introspect performs an introspection query given a query that's expected to be either __schema or __type.

func MakeHttpRequest

func MakeHttpRequest(client *http.Client, method, url string, header http.Header,
	body []byte) (*http.Response, error)

MakeHttpRequest sends an HTTP request using the provided inputs. It returns the HTTP response along with any errors that were encountered. If no client is provided, it uses the defaultHttpClient which has a timeout of 1 minute.

func PrependPath

func PrependPath(err error, pathItem interface{}) error

PrependPath adds the given path item as the first item in the error's path list.

func SetPathIfEmpty

func SetPathIfEmpty(err error, pathItem interface{}) error

SetPathIfEmpty sets error's path with the given path item as the only item in path, only if initially the error had no path.

func Stringify

func Stringify(schema *ast.Schema, originalTypes []string, apolloServiceQuery bool) string

Stringify the schema as a GraphQL SDL string. It's assumed that the schema was built by completeSchema, and so contains an original set of definitions, the definitions from schemaExtras and generated types, queries and mutations.

Any types in originalTypes are printed first, followed by the schemaExtras, and then all generated types, scalars, enums, directives, query and mutations all in alphabetical order. var "apolloServiceQuery" is used to distinguish Schema String from what should be returned as a result of apollo service query. In case of Apollo service query, Schema removes some of the directive definitions which are currently not supported at the gateway.

func SubstituteVarsInBody

func SubstituteVarsInBody(jsonTemplate interface{}, variables map[string]interface{}) interface{}

Given a JSON representation for a body with variables defined, this function substitutes the variables and returns the final JSON. for e.g.

{
		"author" : "$id",
		"name" : "Jerry",
		"age" : 23,
		"post": {
			"id": "$postID"
		}
}

with variables {"id": "0x3", postID: "0x9"} should return

{
		"author" : "0x3",
		"name" : "Jerry",
		"age" : 23,
		"post": {
			"id": "0x9"
		}
}

func SubstituteVarsInURL

func SubstituteVarsInURL(rawURL string, vars map[string]interface{}) (string,
	error)

func Unmarshal

func Unmarshal(data []byte, v interface{}) error

Unmarshal is like json.Unmarshal() except it uses a custom decoder which preserves number precision by unmarshalling them into json.Number.

func ValidatorNoOp

func ValidatorNoOp(
	sch *ast.Schema,
	typ *ast.Definition,
	field *ast.FieldDefinition,
	dir *ast.Directive,
	secrets map[string]x.Sensitive) gqlerror.List

Types

type AuthContainer

type AuthContainer struct {
	Password *RuleNode
	Query    *RuleNode
	Add      *RuleNode
	Update   *RuleNode
	Delete   *RuleNode
}

type EntityRepresentations

type EntityRepresentations struct {
	TypeDefn Type            // the type corresponding to __typename in the representations argument
	KeyField FieldDefinition // the definition of the @key field
	KeyVals  []interface{}   // the list of values corresponding to the key field
	// a map of key field value to the input representation for that value. The keys in this map
	// are the string formatted version of the key field value.
	KeyValToRepresentation map[string]map[string]interface{}
}

EntityRepresentations is the parsed form of the `representations` argument in `_entities` query

type ExecutionTrace

type ExecutionTrace struct {
	Resolvers []*ResolverTrace `json:"resolvers"`
}

ExecutionTrace records all the resolvers

func (*ExecutionTrace) Merge

func (e *ExecutionTrace) Merge(other *ExecutionTrace)

type Extensions

type Extensions struct {
	TouchedUids uint64 `json:"touched_uids,omitempty"`
	Tracing     *Trace `json:"tracing,omitempty"`
	DQLQuery    string `json:"dql_query,omitempty"`
}

Extensions represents GraphQL extensions

func (*Extensions) GetTouchedUids

func (e *Extensions) GetTouchedUids() uint64

GetTouchedUids returns TouchedUids

func (*Extensions) Merge

func (e *Extensions) Merge(ext *Extensions)

Merge merges ext with e

type Field

type Field interface {
	Name() string
	Alias() string
	// DgraphAlias is used as an alias in DQL while rewriting the GraphQL field.
	DgraphAlias() string
	ResponseName() string
	RemoteResponseName() string
	Arguments() map[string]interface{}
	ArgValue(name string) interface{}
	IsArgListType(name string) bool
	IDArgValue() (map[string]string, uint64, error)
	XIDArgs() map[string]string
	SetArgTo(arg string, val interface{})
	Skip() bool
	Include() bool
	// SkipField tells whether to skip this field during completion or not based on:
	//  * @skip
	//  * @include
	//  * __typename: used for skipping fields in abstract types
	//  * seenField: used for skipping when the field has already been seen at the current level
	SkipField(dgraphTypes []string, seenField map[string]bool) bool
	Cascade() []string
	// ApolloRequiredFields returns the fields names which were specified in @requires.
	ApolloRequiredFields() []string
	// CustomRequiredFields returns a map from DgraphAlias to the field definition of the fields
	// which are required to resolve this custom field.
	CustomRequiredFields() map[string]FieldDefinition
	// IsCustomHTTP tells whether this field has @custom(http: {...}) directive on it.
	IsCustomHTTP() bool
	// HasCustomHTTPChild tells whether any descendent of this field has @custom(http: {...}) on it.
	HasCustomHTTPChild() bool
	HasLambdaDirective() bool
	Type() Type
	IsExternal() bool
	SelectionSet() []Field
	Location() x.Location
	DgraphPredicate() string
	Operation() Operation
	// AbstractType tells us whether this field represents a GraphQL Interface/Union.
	AbstractType() bool
	IncludeAbstractField(types []string) bool
	TypeName(dgraphTypes []string) string
	GetObjectName() string
	IsAuthQuery() bool
	CustomHTTPConfig() (*FieldHTTPConfig, error)
	EnumValues() []string
	ConstructedFor() Type
	ConstructedForDgraphPredicate() string
	DgraphPredicateForAggregateField() string
	IsAggregateField() bool
	GqlErrorf(path []interface{}, message string, args ...interface{}) *x.GqlError
	// MaxPathLength finds the max length (including list indexes) of any path in the 'query' f.
	MaxPathLength() int
	// PreAllocatePathSlice is used to pre-allocate a path buffer of the correct size before running
	// CompleteObject on the top level query - means that we aren't reallocating slices multiple
	// times during the complete* functions.
	PreAllocatePathSlice() []interface{}
	// NullValue returns the appropriate null bytes to be written as value in the JSON response for
	// this field.
	//  * If this field is a list field then it returns []byte("[]").
	//  * If it is nullable, it returns []byte("null").
	//  * Otherwise, this field is non-nullable and so it will return a nil slice to indicate that.
	NullValue() []byte
	// NullResponse returns the bytes representing a JSON object to be used for setting the Data
	// field of a Resolved, when this field resolves to a NullValue.
	//  * If this field is a list field then it returns []byte(`{"fieldAlias":[]}`).
	//  * If it is nullable, it returns []byte(`{"fieldAlias":null}`).
	//  * Otherwise, this field is non-nullable and so it will return a nil slice to indicate that.
	// This is useful only for top-level fields like a query or mutation.
	NullResponse() []byte
	// CompleteAlias applies GraphQL alias completion for field to the input buffer buf.
	CompleteAlias(buf *bytes.Buffer)
	// GetAuthMeta returns the Dgraph.Authorization meta information stored in schema
	GetAuthMeta() *authorization.AuthMeta
}

A Field is one field from an Operation.

type FieldDefinition

type FieldDefinition interface {
	Name() string
	DgraphAlias() string
	DgraphPredicate() string
	Type() Type
	ParentType() Type
	IsID() bool
	IsExternal() bool
	HasIDDirective() bool
	HasEmbeddingDirective() bool
	EmbeddingSearchMetric() string
	HasInterfaceArg() bool
	GetDefaultValue(action string) interface{}
	Inverse() FieldDefinition
	WithMemberType(string) FieldDefinition
	// TODO - It might be possible to get rid of ForwardEdge and just use Inverse() always.
	ForwardEdge() FieldDefinition
	// GetAuthMeta returns the Dgraph.Authorization meta information stored in schema
	GetAuthMeta() *authorization.AuthMeta
}

A FieldDefinition is a field as defined in some Type in the schema. As opposed to a Field, which is an instance of a query or mutation asking for a field (which in turn must have a FieldDefinition of the right type in the schema.)

type FieldHTTPConfig

type FieldHTTPConfig struct {
	URL    string
	Method string
	// would be nil if there is no body
	Template       interface{}
	Mode           string
	ForwardHeaders http.Header
	// would be empty for non-GraphQL requests
	RemoteGqlQueryName string
	RemoteGqlQuery     string

	// For the following request
	// graphql: "query($sinput: [SchoolInput]) { schoolNames(schools: $sinput) }"
	// the GraphqlBatchModeArgument would be sinput, we use it to know the GraphQL variable that
	// we should send the data in.
	GraphqlBatchModeArgument string
}

FieldHTTPConfig contains the config needed to resolve a field using a remote HTTP endpoint which could a GraphQL or a REST endpoint.

func (*FieldHTTPConfig) MakeAndDecodeHTTPRequest

func (fconf *FieldHTTPConfig) MakeAndDecodeHTTPRequest(client *http.Client, url string,
	body interface{}, field Field) (interface{}, x.GqlErrorList, x.GqlErrorList)

MakeAndDecodeHTTPRequest sends an HTTP request using the given url and body and then decodes the response correctly based on whether it was a GraphQL or REST request. It returns the decoded response along with either soft or hard errors. Soft error means one can assume that the response is valid and continue the normal execution. Hard error means there will be no response returned and one must stop the normal execution flow. For GraphQL requests, the GraphQL errors returned from the remote endpoint are considered soft errors. Any other kind of error is a hard error. For REST requests, any error is a hard error, including those returned from the remote endpoint.

type GenerateDirectiveParams

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

Struct to store parameters of @generate directive

type Handler

type Handler interface {
	MetaInfo() *metaInfo
	DGSchema() string
	GQLSchema() string
	GQLSchemaWithoutApolloExtras() string
}

A Handler can produce valid GraphQL and Dgraph schemas given an input of types and relationships

func NewHandler

func NewHandler(input string, apolloServiceQuery bool) (Handler, error)

NewHandler processes the input schema. If there are no errors, it returns a valid Handler, otherwise it returns nil and an error.

type IntrospectionRequest

type IntrospectionRequest struct {
	Query string `json:"query"`
}

type LabeledOffsetDuration

type LabeledOffsetDuration struct {
	Label string `json:"label"`
	OffsetDuration
}

LabeledOffsetDuration is an OffsetDuration with a string label.

type Mutation

type Mutation interface {
	Field
	MutationType() MutationType
	MutatedType() Type
	QueryField() Field
	NumUidsField() Field
	HasLambdaOnMutate() bool
}

A Mutation is a field (from the schema's Mutation type) from an Operation

type MutationType

type MutationType string

MutationType is currently supported mutations

type OffsetDuration

type OffsetDuration struct {

	// Offset in nanoseconds, relative to the request start, as an integer
	StartOffset int64 `json:"startOffset"`

	// Duration in nanoseconds, relative to start of operation, as an integer.
	Duration int64 `json:"duration"`
}

An OffsetDuration records the offset start and duration of GraphQL parsing/validation.

type OffsetTimer

type OffsetTimer interface {
	Start()
	Stop()
}

An OffsetTimer is used to fill out an OffsetDuration. Start starts the timer and calculates the offset. Stop calculates the duration.

type Operation

type Operation interface {
	Queries() []Query
	Mutations() []Mutation
	Schema() Schema
	IsQuery() bool
	IsMutation() bool
	IsSubscription() bool
	CacheControl() string
}

An Operation is a single valid GraphQL operation. It contains either Queries or Mutations, but not both. Subscriptions are not yet supported.

type PersistedQuery

type PersistedQuery struct {
	Sha256Hash string
}

PersistedQuery represents the query struct received from clients like Apollo

type Query

type Query interface {
	Field
	QueryType() QueryType
	DQLQuery() string
	Rename(newName string)
	// RepresentationsArg returns a parsed version of the `representations` argument for `_entities`
	// query
	RepresentationsArg() (*EntityRepresentations, error)
	AuthFor(jwtVars map[string]interface{}) Query
}

A Query is a field (from the schema's Query type) from an Operation

type QueryType

type QueryType string

QueryType is currently supported queries

type RBACQuery

type RBACQuery struct {
	Variable string
	Operator string
	Operand  interface{}
	// contains filtered or unexported fields
}

func (*RBACQuery) EvaluateRBACRule

func (rq *RBACQuery) EvaluateRBACRule(av map[string]interface{}) RuleResult

EvaluateRBACRule evaluates the auth token based on the auth query There are two cases here: 1. Auth token has an array of values for the variable. 2. Auth token has non-array value for the variable. match would be deep equal except for regex match in case of regexp operator. In case array one match would made the rule positive. For example, Rule {$USER: { eq:"uid"}} and token $USER:["u", "id", "uid"] result in match. Rule {$USER: { in: ["uid", "xid"]}} and token $USER:["u", "id", "uid"] result in match

type Request

type Request struct {
	Query         string                 `json:"query"`
	OperationName string                 `json:"operationName"`
	Variables     map[string]interface{} `json:"variables"`
	Extensions    RequestExtensions
	Header        http.Header `json:"-"` // no need to marshal headers while generating poll hash
}

A Request represents a GraphQL request. It makes no guarantees that the request is valid.

type RequestExtensions

type RequestExtensions struct {
	PersistedQuery PersistedQuery
}

RequestExtensions represents extensions recieved in requests

type ResolverTrace

type ResolverTrace struct {

	// the response path of the current resolver - same format as path in error
	// result format specified in the GraphQL specification
	Path       []interface{} `json:"path"`
	ParentType string        `json:"parentType"`
	FieldName  string        `json:"fieldName"`
	ReturnType string        `json:"returnType"`

	// Offset relative to request start and total duration or resolving
	OffsetDuration

	// Dgraph isn't in Apollo tracing.  It records the offsets and times
	// of Dgraph operations for the query/mutation (including network latency)
	// in nanoseconds.
	Dgraph []*LabeledOffsetDuration `json:"dgraph"`
}

A ResolverTrace is a trace of one resolver. In a traditional GraphQL server, resolving say a query, would result in a ResolverTrace for the query itself (with duration spanning the time to resolve the entire query) and traces for every field in the query (with duration for just that field).

Dgraph GraphQL layer resolves Queries in a single step, so each query has only one associated ResolverTrace. Mutations require two steps - the mutation itself and the following query. So mutations will have a ResolverTrace with duration spanning the entire mutation (including the query part), and a trace of the query. To give insight into what's actually happening there, the Dgraph time is also recorded. So for a mutation you can see total duration, mutation duration, query duration and also amount of time spent by the API orchestrating the mutation/query.

type Response

type Response struct {
	Errors     x.GqlErrorList
	Data       bytes.Buffer
	Extensions *Extensions
	Header     http.Header
	// contains filtered or unexported fields
}

Response represents a GraphQL response

func ErrorResponse

func ErrorResponse(err error) *Response

ErrorResponse formats an error as a list of GraphQL errors and builds a response with that error list and no data. Because it doesn't add data, it should be used before starting execution - GraphQL spec requires no data if an error is detected before execution begins.

func (*Response) AddData

func (r *Response) AddData(p []byte)

AddData adds p to r's data buffer.

If p is empty or r.SetDataNull() has been called earlier, the call has no effect.

If r.Data is empty before the call, then r.Data becomes {p}. If r.Data contains data it always looks like {f,g,...}, and adding to that results in {f,g,...,p}.

func (*Response) GetExtensions

func (r *Response) GetExtensions() *Extensions

GetExtensions returns a *Extensions

func (*Response) MergeExtensions

func (r *Response) MergeExtensions(ext *Extensions)

MergeExtensions merges the extensions given in ext to r. If r.Extensions is nil before the call, then r.Extensions becomes ext. Otherwise, r.Extensions gets merged with ext.

func (*Response) Output

func (r *Response) Output() interface{}

Output returns json interface of the response

func (*Response) SetDataNull

func (r *Response) SetDataNull()

SetDataNull sets r's data buffer to contain the bytes representing a null. Once this has been called on r, any further call to AddData has no effect.

func (*Response) WithError

func (r *Response) WithError(err error)

WithError generates GraphQL errors from err and records those in r.

func (*Response) WriteTo

func (r *Response) WriteTo(w io.Writer) (int64, error)

WriteTo writes the GraphQL response as unindented JSON to w and returns the number of bytes written and error, if any.

type RuleNode

type RuleNode struct {
	Or        []*RuleNode
	And       []*RuleNode
	Not       *RuleNode
	Rule      Query
	DQLRule   *dql.GraphQuery
	RBACRule  *RBACQuery
	Variables ast.VariableDefinitionList
}

func (*RuleNode) EvaluateStatic

func (node *RuleNode) EvaluateStatic(av map[string]interface{}) RuleResult

type RuleResult

type RuleResult int
const (
	Uncertain RuleResult = iota
	Positive
	Negative
)

type Schema

type Schema interface {
	Operation(r *Request) (Operation, error)
	Queries(t QueryType) []string
	Mutations(t MutationType) []string
	IsFederated() bool
	SetMeta(meta *metaInfo)
	Meta() *metaInfo
}

Schema represents a valid GraphQL schema

func AsSchema

func AsSchema(s *ast.Schema, ns uint64) (Schema, error)

AsSchema wraps a github.com/dgraph-io/gqlparser/ast.Schema.

func FromString

func FromString(schema string, ns uint64) (Schema, error)

FromString builds a GraphQL Schema from input string, or returns any parsing or validation errors.

type TimerFactory

type TimerFactory interface {
	NewOffsetTimer(storeTo *OffsetDuration) OffsetTimer
}

A TimerFactory makes offset timers that can be used to fill out an OffsetDuration.

func NewOffsetTimerFactory

func NewOffsetTimerFactory(offsetFrom time.Time) TimerFactory

NewOffsetTimerFactory creates a new TimerFactory given offsetFrom as the reference time to calculate the OffsetDuration.StartOffset from.

type Trace

type Trace struct {

	// Apollo Tracing Spec version
	Version int `json:"version"`

	// Timestamps in RFC 3339 nano format.
	StartTime string `json:"startTime,"`
	EndTime   string `json:"endTime"`

	// Duration in nanoseconds, relative to the request start, as an integer.
	Duration int64 `json:"duration"`

	// Parsing and Validation not required at the moment.
	//Parsing    *OffsetDuration `json:"parsing,omitempty"`
	//Validation *OffsetDuration `json:"validation,omitempty"`
	Execution *ExecutionTrace `json:"execution,omitempty"`
}

Trace : Apollo Tracing is a GraphQL extension for tracing resolver performance.Response https://github.com/apollographql/apollo-tracing Not part of the standard itself, it gets reported in GraphQL "extensions". It's for reporting tracing data through all the resolvers in a GraphQL query. Our results aren't as 'deep' as a traditional GraphQL server in that the Dgraph layer resolves in a single step, rather than iteratively. So we'll report on all the top level queries/mutations.

Currently, only reporting in the GraphQL result, but also planning to allow exposing to Apollo Engine as per: https://www.apollographql.com/docs/references/setup-analytics/#engine-reporting-endpoint

func (*Trace) Merge

func (t *Trace) Merge(other *Trace)

type Type

type Type interface {
	Field(name string) FieldDefinition
	Fields() []FieldDefinition
	IDField() FieldDefinition
	XIDFields() []FieldDefinition
	InterfaceImplHasAuthRules() bool
	PasswordField() FieldDefinition
	Name() string
	DgraphName() string
	DgraphPredicate(fld string) string
	Nullable() bool
	// true if this is a union type
	IsUnion() bool
	IsInterface() bool
	// returns a list of member types for this union
	UnionMembers([]interface{}) []Type
	ListType() Type
	Interfaces() []string
	ImplementingTypes() []Type
	EnsureNonNulls(map[string]interface{}, string) error
	FieldOriginatedFrom(fieldName string) (Type, bool)
	AuthRules() *TypeAuth
	IsGeo() bool
	IsAggregateResult() bool
	IsInbuiltOrEnumType() bool
	fmt.Stringer
}

A Type is a GraphQL type like: Float, T, T! and [T!]!. If it's not a list, then ListType is nil. If it's an object type then Field gets field definitions by name from the definition of the type; IDField gets the ID field of the type.

type TypeAuth

type TypeAuth struct {
	Rules  *AuthContainer
	Fields map[string]*AuthContainer
}

Jump to

Keyboard shortcuts

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