Documentation ¶
Overview ¶
Copyright 2020 凯斐德科技(杭州)有限公司 (Karfield Technology, ltd.)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func BeforeResolve(resolve interface{}, checker interface{}) (interface{}, error)
- func HandleHTTPOptions(w http.ResponseWriter, r *http.Request)
- type Arguments
- type ContextError
- type CustomParserInput
- type Engine
- func (engine *Engine) AddMutation(resolve interface{}, name string, description string, tags ...string) error
- func (engine *Engine) AddQuery(resolve interface{}, name string, description string, tags ...string) error
- func (engine *Engine) AddSubscription(onSubscribed, onUnsubscribed interface{}, name string, description string, ...) error
- func (engine *Engine) AddSubscriptionAuthentication(auth func(authToken string) (context.Context, error))
- func (engine *Engine) Init() (err error)
- func (engine *Engine) NewMutation(resolve interface{}) MutationBuilder
- func (engine *Engine) NewQuery(resolve interface{}) QueryBuilder
- func (engine *Engine) NewSubscription(onSubscribed interface{}) SubscriptionBuilder
- func (engine *Engine) PreRegisterInterface(interfacePrototype, modelPrototype interface{}) error
- func (engine *Engine) PreRegisterUnion(interfacePrototype interface{}, types ...interface{}) error
- func (engine *Engine) RegisterEnum(prototype interface{}) (*graphql.Enum, error)
- func (engine *Engine) RegisterInput(prototype interface{}) (*graphql.InputObject, error)
- func (engine *Engine) RegisterObject(prototype interface{}) (*graphql.Object, error)
- func (engine *Engine) RegisterPlugin(name string, plugin Plugin)
- func (engine *Engine) RegisterScalar(prototype interface{}) (*graphql.Scalar, error)
- func (engine *Engine) RegisterType(prototype interface{}) (graphql.Type, error)
- func (engine *Engine) Schema() graphql.Schema
- func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (engine *Engine) ServeWebsocket(w http.ResponseWriter, r *http.Request)
- type Enum
- type EnumValue
- type EnumValueMapping
- type Error
- type FastRequestContext
- type FastResponseContext
- type FieldSelection
- type ID
- type Input
- type Interface
- type IsGraphQLArguments
- type IsGraphQLInput
- type IsGraphQLInterface
- type IsGraphQLObject
- type MutationBuilder
- type NameAlterableEnum
- type NameAlterableInput
- type NameAlterableInterface
- type NameAlterableObject
- type NameAlterableScalar
- type Object
- type ObjectDelegation
- type Options
- type Plugin
- type QueryBuilder
- type RequestContext
- type RequestContextBeforeCalled
- type RequestOptions
- type ResponseContext
- type Scalar
- type ScalarWithASTParsing
- type Subscription
- type SubscriptionBuilder
- type SubscriptionSession
- type Tracing
- type TracingExecution
- type TracingRecord
- type TracingResolveRecord
- type Upload
Constants ¶
View Source
const ( ContentTypeJSON = "application/json" ContentTypeGraphQL = "application/graphql" ContentTypeFormURLEncoded = "application/x-www-form-urlencoded" ContextTypeMultipart = "multipart/form-data" )
View Source
const (
DefaultMultipartParsingBufferSize = 10 * 1024 * 1024
)
Variables ¶
View Source
var Duration = graphql.NewScalar(graphql.ScalarConfig{ Name: "Duration", Description: "time duration", Serialize: func(value interface{}) interface{} { switch value := value.(type) { case time.Duration: return value.String() case *time.Duration: return value.String() } return nil }, ParseValue: func(value interface{}) interface{} { switch value := value.(type) { case string: d, _ := time.ParseDuration(value) return d case *string: d, _ := time.ParseDuration(*value) return d } return nil }, ParseLiteral: func(valueAST ast.Value) interface{} { switch valueAST := valueAST.(type) { case *ast.StringValue: d, _ := time.ParseDuration(valueAST.Value) return d } return nil }, })
View Source
var UploadScalar = graphql.NewScalar(graphql.ScalarConfig{ Name: "Upload", Description: "The `Upload` scalar type represents a file upload.", Serialize: func(value interface{}) interface{} { panic("Upload serialization unsupported.") return nil }, ParseValue: func(value interface{}) interface{} { return value }, ParseLiteral: func(valueAST ast.Value) interface{} { panic("Upload literal unsupported.") }, })
View Source
var Void = graphql.NewScalar(graphql.ScalarConfig{ Name: "Void", Description: "void", Serialize: func(value interface{}) interface{} { return "0" }, ParseValue: func(value interface{}) interface{} { return 0 }, ParseLiteral: func(valueAST ast.Value) interface{} { return 0 }, })
Functions ¶
func BeforeResolve ¶
func BeforeResolve(resolve interface{}, checker interface{}) (interface{}, error)
func HandleHTTPOptions ¶
func HandleHTTPOptions(w http.ResponseWriter, r *http.Request)
Types ¶
type ContextError ¶
type ContextError interface { gqlerrors.ExtendedError StatusCode() int }
type CustomParserInput ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) AddMutation ¶
func (*Engine) AddSubscription ¶
func (*Engine) AddSubscriptionAuthentication ¶
func (*Engine) NewMutation ¶
func (engine *Engine) NewMutation(resolve interface{}) MutationBuilder
func (*Engine) NewQuery ¶
func (engine *Engine) NewQuery(resolve interface{}) QueryBuilder
func (*Engine) NewSubscription ¶
func (engine *Engine) NewSubscription(onSubscribed interface{}) SubscriptionBuilder
func (*Engine) PreRegisterInterface ¶
func (*Engine) PreRegisterUnion ¶
func (*Engine) RegisterEnum ¶
func (*Engine) RegisterInput ¶
func (engine *Engine) RegisterInput(prototype interface{}) (*graphql.InputObject, error)
func (*Engine) RegisterObject ¶
func (*Engine) RegisterPlugin ¶
func (*Engine) RegisterScalar ¶
func (*Engine) RegisterType ¶
func (*Engine) ServeWebsocket ¶
func (engine *Engine) ServeWebsocket(w http.ResponseWriter, r *http.Request)
type Enum ¶
type Enum interface { GraphQLEnumDescription() string GraphQLEnumValues() EnumValueMapping }
type EnumValueMapping ¶
type FastRequestContext ¶
type FastRequestContext interface { RequestContext GraphQLContextFromFastHTTPRequest(ctx *fasthttp.RequestCtx) error }
type FastResponseContext ¶
type FastResponseContext interface { ResponseContext GraphQLContextToFastHTTPResponse(ctx *fasthttp.RequestCtx) error }
type FieldSelection ¶
type IsGraphQLArguments ¶
type IsGraphQLArguments struct{}
type IsGraphQLInput ¶
type IsGraphQLInput struct{}
type IsGraphQLInterface ¶
type IsGraphQLInterface struct{}
type IsGraphQLObject ¶
type IsGraphQLObject struct{}
type MutationBuilder ¶
type MutationBuilder interface { Name(name string) MutationBuilder Description(desc string) MutationBuilder Tags(tags ...string) MutationBuilder WrapWith(fn interface{}) MutationBuilder }
type NameAlterableEnum ¶
type NameAlterableInput ¶
type NameAlterableInterface ¶
type NameAlterableObject ¶
type NameAlterableScalar ¶
type ObjectDelegation ¶
type ObjectDelegation interface { Object GraphQLObjectDelegation() interface{} }
type Plugin ¶
type Plugin interface { BeforeCheckArgumentsStruct(baseType reflect.Type) interface{} CheckArgumentsEmbeddedField(pluginData interface{}, field *reflect.StructField) error CheckArgument(pluginData interface{}, name string, typ graphql.Type, tag *reflect.StructTag, goType reflect.Type, defaultValue interface{}) error MatchAndCallArgumentsMethod(pluginData interface{}, method reflect.Method, prototype reflect.Value) error AfterCheckArgumentsStruct(pluginData interface{}) error BeforeCheckObjectStruct(baseType reflect.Type) interface{} CheckObjectEmbeddedFieldTags(pluginData interface{}, field *reflect.StructField) error CheckObjectField(pluginData interface{}, name string, typ graphql.Type, tag *reflect.StructTag, goType reflect.Type) error MatchAndCallObjectMethod(pluginData interface{}, method reflect.Method, prototype reflect.Value) error AfterCheckObjectStruct(pluginData interface{}, obj *graphql.Object) error BeforeCheckInputStruct(baseType reflect.Type) interface{} CheckInputObjectEmbeddedFieldTags(pluginData interface{}, field *reflect.StructField) error CheckInputObjectField(pluginData interface{}, name string, typ graphql.Type, tag *reflect.StructTag, goType reflect.Type) error MatchAndCallInputObjectMethod(pluginData interface{}, method reflect.Method, prototype reflect.Value) error AfterCheckInputStruct(pluginData interface{}, input *graphql.InputObject) error CheckQueryOperation(operation string, arguments reflect.Type, typ reflect.Type) CheckMutationOperation(operation string, arguments reflect.Type, typ reflect.Type) }
type QueryBuilder ¶
type QueryBuilder interface { Name(name string) QueryBuilder Description(desc string) QueryBuilder Tags(tags ...string) QueryBuilder WrapWith(fn interface{}) QueryBuilder }
type RequestContext ¶
type RequestContextBeforeCalled ¶
type RequestContextBeforeCalled interface { RequestContext GraphQLCheckErrorBeforeCalled() error }
type RequestOptions ¶
type ResponseContext ¶
type ResponseContext interface {
GraphQLContextToHTTPResponse(w http.ResponseWriter) error
}
type Scalar ¶
type Scalar interface { GraphQLScalarSerialize() interface{} GraphQLScalarParseValue(value interface{}) GraphQLScalarDescription() string }
type ScalarWithASTParsing ¶
type Subscription ¶
type SubscriptionBuilder ¶
type SubscriptionBuilder interface { Name(name string) SubscriptionBuilder Description(desc string) SubscriptionBuilder OnUnsubscribed(unsubscribed interface{}) SubscriptionBuilder Tags(tags ...string) SubscriptionBuilder WrapWith(fn interface{}) SubscriptionBuilder }
type SubscriptionSession ¶
type SubscriptionSession interface {
GraphQLSubscriptionSession()
}
type Tracing ¶
type Tracing struct { Version int `json:"version"` StartTime time.Time `json:"startTime"` EndTime time.Time `json:"endTime"` Duration int64 `json:"duration"` Parsing TracingRecord `json:"parsing"` Validation TracingRecord `json:"validation"` Execution TracingExecution `json:"execution"` }
type TracingExecution ¶
type TracingExecution struct { TracingRecord Resolvers []*TracingResolveRecord `json:"resolvers"` }
type TracingRecord ¶
type TracingResolveRecord ¶
type TracingResolveRecord struct { TracingRecord Path []interface{} `json:"path"` ParentType string `json:"parentType"` FieldName string `json:"fieldName"` ReturnType string `json:"returnType"` }
type Upload ¶
type Upload struct {
*multipart.FileHeader
}
Click to show internal directories.
Click to hide internal directories.