Documentation ¶
Index ¶
- Constants
- Variables
- func ErrResolver(err error) graphql.FieldResolveFn
- func PassthroughResolver(p graphql.ResolveParams) (any, error)
- func ResolveIDable[T any](rs Resolvers, name string, obj ObjectResolver)
- func ToResolver[P any, A any, R any](f func(*core.Context, P, A) (R, error)) graphql.FieldResolveFn
- func ToVoidResolver[P any, A any](f func(*core.Context, P, A) error) graphql.FieldResolveFn
- type EnvVariable
- type ExecutableSchema
- type ExposedPort
- type FieldResolvers
- type FunctionContext
- type FunctionContextCache
- type Handler
- type HandlerConfig
- type IDableObjectResolver
- type InitializeArgs
- type InvalidInputError
- type Label
- type MergedSchemas
- func (s *MergedSchemas) HTTPHandler(moduleDigest digest.Digest) (http.Handler, error)
- func (s *MergedSchemas) MuxEndpoint(path string, handler http.Handler, moduleDigest digest.Digest) error
- func (s *MergedSchemas) Schema(moduleDigest digest.Digest) (*graphql.Schema, error)
- func (s *MergedSchemas) ShutdownClient(ctx context.Context, client *engine.ClientMetadata) error
- type ObjectResolver
- type RequestOptions
- type Resolver
- type Resolvers
- type ResultCallbackFn
- type RootObjectFn
- type SDK
- type ScalarResolver
- type SecretPlaintext
- type StaticSchemaParams
Constants ¶
const ( ContentTypeJSON = "application/json" ContentTypeGraphQL = "application/graphql" ContentTypeFormURLEncoded = "application/x-www-form-urlencoded" )
Variables ¶
var ( ErrMergeTypeConflict = errors.New("object type re-defined") ErrMergeFieldConflict = errors.New("field re-defined") ErrMergeScalarConflict = errors.New("scalar re-defined") )
var Cache string
var Container string
var Directory string
var File string
var Function string
var Git string
var HTTP string
var Host string
var InternalSDK string
var Module string
var Platform string
var Query string
var Secret string
var Service string
var Socket string
Functions ¶
func ErrResolver ¶ added in v0.8.0
func ErrResolver(err error) graphql.FieldResolveFn
func PassthroughResolver ¶ added in v0.8.0
func PassthroughResolver(p graphql.ResolveParams) (any, error)
func ResolveIDable ¶ added in v0.9.0
func ResolveIDable[T any](rs Resolvers, name string, obj ObjectResolver)
func ToResolver ¶ added in v0.8.0
ToResolver transforms any function f with a *Context, a parent P and some args A that returns a Response R and an error into a graphql resolver graphql.FieldResolveFn.
func ToVoidResolver ¶ added in v0.8.8
Types ¶
type EnvVariable ¶
type ExecutableSchema ¶ added in v0.8.0
type ExecutableSchema interface { Name() string Schema() string Resolvers() Resolvers Dependencies() []ExecutableSchema }
func StaticSchema ¶ added in v0.8.0
func StaticSchema(p StaticSchemaParams) ExecutableSchema
type ExposedPort ¶ added in v0.3.13
type ExposedPort struct { Port int `json:"port"` Protocol string `json:"protocol"` Description *string `json:"description,omitempty"` }
NB(vito): we have to use a different type with a regular string Protocol field so that the enum mapping works.
type FieldResolvers ¶ added in v0.8.0
type FieldResolvers interface { Resolver Fields() map[string]graphql.FieldResolveFn SetField(string, graphql.FieldResolveFn) }
type FunctionContext ¶ added in v0.8.8
type FunctionContext struct { Module *core.Module CurrentCall *core.FunctionCall }
FunctionContext holds the metadata of a function call. Used to support the currentModule and currentFunctionCall APIs.
func (*FunctionContext) Digest ¶ added in v0.8.8
func (fnCtx *FunctionContext) Digest() (digest.Digest, error)
type FunctionContextCache ¶ added in v0.8.8
type FunctionContextCache core.CacheMap[digest.Digest, *FunctionContext]
FunctionContextCache stores the mapping of FunctionContext's digest -> FunctionContext. This enables us to pass just the digest along the client metadata rather than massive serialized objects.
func NewFunctionContextCache ¶ added in v0.8.8
func NewFunctionContextCache() *FunctionContextCache
func (*FunctionContextCache) FunctionContextFrom ¶ added in v0.8.8
func (cache *FunctionContextCache) FunctionContextFrom(ctx context.Context) (*FunctionContext, error)
func (*FunctionContextCache) WithFunctionContext ¶ added in v0.8.8
func (cache *FunctionContextCache) WithFunctionContext(ctx *core.Context, fnCtx *FunctionContext) (*core.Context, error)
type Handler ¶ added in v0.8.8
func NewHandler ¶ added in v0.8.8
func NewHandler(p *HandlerConfig) *Handler
func (*Handler) ContextHandler ¶ added in v0.8.8
ContextHandler provides an entrypoint into executing graphQL queries with a user-provided context.
type HandlerConfig ¶ added in v0.8.8
type HandlerConfig struct { Schema *graphql.Schema Pretty bool RootObjectFn RootObjectFn ResultCallbackFn ResultCallbackFn FormatErrorFn func(err error) gqlerrors.FormattedError }
func NewConfig ¶ added in v0.8.8
func NewConfig() *HandlerConfig
type IDableObjectResolver ¶ added in v0.8.0
type IDableObjectResolver interface { FromID(id string) (any, error) ToID(any) (string, error) Resolver }
func ToIDableObjectResolver ¶ added in v0.8.0
func ToIDableObjectResolver[T any, I ~string](idToObject func(I) (*T, error), r ObjectResolver) IDableObjectResolver
type InitializeArgs ¶
type InvalidInputError ¶ added in v0.8.0
type InvalidInputError struct {
Err error
}
func (InvalidInputError) Error ¶ added in v0.8.0
func (e InvalidInputError) Error() string
func (InvalidInputError) Unwrap ¶ added in v0.8.0
func (e InvalidInputError) Unwrap() error
type MergedSchemas ¶ added in v0.8.0
type MergedSchemas struct {
// contains filtered or unexported fields
}
func New ¶
func New(params InitializeArgs) (*MergedSchemas, error)
func (*MergedSchemas) HTTPHandler ¶ added in v0.8.8
func (s *MergedSchemas) HTTPHandler(moduleDigest digest.Digest) (http.Handler, error)
func (*MergedSchemas) MuxEndpoint ¶ added in v0.8.8
func (s *MergedSchemas) MuxEndpoint(path string, handler http.Handler, moduleDigest digest.Digest) error
func (*MergedSchemas) Schema ¶ added in v0.8.0
func (s *MergedSchemas) Schema(moduleDigest digest.Digest) (*graphql.Schema, error)
func (*MergedSchemas) ShutdownClient ¶ added in v0.8.5
func (s *MergedSchemas) ShutdownClient(ctx context.Context, client *engine.ClientMetadata) error
type ObjectResolver ¶ added in v0.8.0
type ObjectResolver map[string]graphql.FieldResolveFn
func (ObjectResolver) Fields ¶ added in v0.8.0
func (r ObjectResolver) Fields() map[string]graphql.FieldResolveFn
func (ObjectResolver) SetField ¶ added in v0.8.0
func (r ObjectResolver) SetField(name string, fn graphql.FieldResolveFn)
type RequestOptions ¶ added in v0.8.8
type RequestOptions struct { Query string `json:"query" url:"query" schema:"query"` Variables map[string]interface{} `json:"variables" url:"variables" schema:"variables"` OperationName string `json:"operationName" url:"operationName" schema:"operationName"` }
func NewRequestOptions ¶ added in v0.8.8
func NewRequestOptions(r *http.Request) *RequestOptions
RequestOptions Parses a http.Request into GraphQL request options struct
type Resolver ¶ added in v0.8.0
type Resolver interface {
// contains filtered or unexported methods
}
type ResultCallbackFn ¶ added in v0.8.8
type RootObjectFn ¶ added in v0.8.8
RootObjectFn allows a user to generate a RootObject per request
type SDK ¶ added in v0.9.0
type SDK interface { /* Codegen generates code for the module at the given source directory and subpath. The Code field of the returned GeneratedCode object should be the generated contents of the module sourceDirSubpath, in the case where that's different than the root of the sourceDir. */ Codegen(ctx *core.Context, sourceDir *core.Directory, sourceDirSubpath string) (*core.GeneratedCode, error) // Runtime returns a container that is used to execute module code at runtime in the Dagger engine. Runtime(ctx *core.Context, sourceDir *core.Directory, sourceDirSubpath string) (*core.Container, error) }
An SDK is an implementation of the functionality needed to generate code for and execute a module.
There is one special SDK, the Go SDK, which is implemented in `goSDK` below. It's used as the "seed" for all other SDK implementations.
All other SDKs are themselves implemented as Modules, with Functions matching the two defined in this SDK interface.
An SDK Module needs to choose its own SDK for its implementation. This can be "well-known" built-in SDKs like "go", "python", etc. Or it can be any external module as specified with a module ref.
You can thus think of SDK Modules as a DAG of dependencies, with each SDK using a different SDK to implement its Module, with the Go SDK as the root of the DAG and the only one without any dependencies.
Built-in SDKs are also a bit special in that they come bundled w/ the engine container image, which allows them to be used without hard dependencies on the internet. They are loaded w/ the `loadBuiltinSDK` function below, which loads them as modules from the engine container.
type ScalarResolver ¶ added in v0.8.0
type ScalarResolver struct { Serialize graphql.SerializeFn ParseValue graphql.ParseValueFn ParseLiteral graphql.ParseLiteralFn }
type SecretPlaintext ¶ added in v0.6.0
type SecretPlaintext string
func (SecretPlaintext) MarshalText ¶ added in v0.6.0
func (s SecretPlaintext) MarshalText() ([]byte, error)
This method ensures that the progrock vertex info does not display the plaintext.
type StaticSchemaParams ¶ added in v0.8.0
type StaticSchemaParams struct { Name string Schema string Resolvers Resolvers Dependencies []ExecutableSchema }