Documentation
¶
Index ¶
- Constants
- Variables
- func AssembleGraphQLRequestInput(variables, query, header []byte, url, method string) []byte
- func AssembleGraphQLRequestInputSplitVariables(query, header []byte, url, method string) (prefix, suffix string, err error)
- func Do(client *http.Client, ctx context.Context, baseHeaders http.Header, ...) (data []byte, err error)
- func DoMultipartForm(client *http.Client, ctx context.Context, baseHeaders http.Header, ...) (data []byte, err error)
- func GetSubscriptionInput(input []byte) (url, header, body []byte)
- func IsInputFlagSet(input []byte, flagName string) bool
- func SetForwardedClientHeaderNames(input, headers []byte) []byte
- func SetForwardedClientHeaderRegularExpressions(input, headers []byte) []byte
- func SetInputBody(input, body []byte) []byte
- func SetInputBodyWithPath(input, body []byte, path string) []byte
- func SetInputFlag(input []byte, flagName string) []byte
- func SetInputHeader(input, headers []byte) []byte
- func SetInputHost(input, host []byte) []byte
- func SetInputMethod(input, method []byte) []byte
- func SetInputPath(input, path []byte) []byte
- func SetInputQueryParams(input, queryParams []byte) []byte
- func SetInputScheme(input, scheme []byte) []byte
- func SetInputURL(input, url []byte) []byte
- func SetInputURLEncodeBody(input []byte, urlEncodeBody bool) []byte
- func SetInputWSSubprotocol(input, wsSubProtocol []byte) []byte
- func SetUndefinedVariables(data []byte, undefinedVariables []string) ([]byte, error)
- func UndefinedVariables(data []byte) []string
- func WithHTTPClientSizeHint(ctx context.Context, size int) context.Context
- type FileUpload
- type ResponseContext
- type TraceHTTP
- type TraceHTTPRequest
- type TraceHTTPResponse
Constants ¶
const ( PATH = "path" URL = "url" URLENCODE_BODY = "url_encode_body" BASEURL = "base_url" METHOD = "method" BODY = "body" HEADER = "header" QUERYPARAMS = "query_params" USE_SSE = "use_sse" SSE_METHOD_POST = "sse_method_post" SCHEME = "scheme" HOST = "host" UNDEFINED_VARIABLES = "undefined" FORWARDED_CLIENT_HEADER_NAMES = "forwarded_client_header_names" FORWARDED_CLIENT_HEADER_REGULAR_EXPRESSIONS = "forwarded_client_header_regular_expressions" TRACE = "__trace__" WsSubProtocol = "ws_sub_protocol" )
const ( ContentEncodingHeader = "Content-Encoding" AcceptEncodingHeader = "Accept-Encoding" AcceptHeader = "Accept" ContentTypeHeader = "Content-Type" ContentLengthHeader = "Content-Length" EncodingGzip = "gzip" EncodingDeflate = "deflate" ContentTypeJSON = "application/json" )
Variables ¶
Functions ¶
func AssembleGraphQLRequestInput ¶ added in v2.16.0
AssembleGraphQLRequestInput builds the upstream GraphQL request input with an explicit, code-defined key order:
{"method":M,"url":U,"header":H,"body":{"query":Q,"variables":V}}
Empty components are omitted (a "null" header counts as empty); when every component is empty the result is nil. Each component passes through wrapQuotesIfString exactly like the sjson-based Set* helpers it replaces.
The order is constructed directly rather than via sjson because sjson's placement of NEW keys is version-dependent (v1.0.4 prepends, v1.2.5 appends): assembling through sjson made the byte layout — and the split invariant of AssembleGraphQLRequestInputSplitVariables — depend on which sjson version a consumer build resolves.
func AssembleGraphQLRequestInputSplitVariables ¶ added in v2.16.0
func AssembleGraphQLRequestInputSplitVariables(query, header []byte, url, method string) (prefix, suffix string, err error)
AssembleGraphQLRequestInputSplitVariables assembles the same envelope as AssembleGraphQLRequestInput but returns it split around the (empty) body variables object: prefix ends with `"variables":{`, suffix begins with `}`. Callers that render the variables object themselves (the merged MultiEntityFetch input template) write their content between the two halves, which reconstructs a byte-identical envelope by construction.
The split point is knowable without scanning: AssembleGraphQLRequestInput writes body as the root object's last member and variables as body's last member by explicit construction, so the assembled document always ENDS with `"variables":{}}}` — see TestAssembleGraphQLRequestInput, which pins the full key order. Splitting off that fixed-length tail cannot be confused by a query or header that happens to contain the same text (a query is a JSON string, so its quotes are escaped, and any raw header occurrence is necessarily earlier in the document). A document that does not end with the tail means the assembly changed; that is reported as an error rather than guessed at.
func DoMultipartForm ¶
func GetSubscriptionInput ¶
func IsInputFlagSet ¶
func SetInputBody ¶
func SetInputBodyWithPath ¶
func SetInputFlag ¶
func SetInputHeader ¶
func SetInputHost ¶
func SetInputMethod ¶
func SetInputPath ¶
func SetInputQueryParams ¶
func SetInputScheme ¶
func SetInputURL ¶
func SetInputURLEncodeBody ¶
func SetInputWSSubprotocol ¶
func SetUndefinedVariables ¶
func UndefinedVariables ¶
func WithHTTPClientSizeHint ¶
WithHTTPClientSizeHint allows the engine to keep track of response sizes per subgraph fetch If a hint is supplied, we can create a buffer of size close to the required size This reduces allocations by reducing the buffer grow calls, which always copies the buffer
Types ¶
type FileUpload ¶
type FileUpload struct {
// contains filtered or unexported fields
}
func NewFileUpload ¶
func NewFileUpload(path string, name string, variablePath string) *FileUpload
func (*FileUpload) Name ¶
func (f *FileUpload) Name() string
func (*FileUpload) Path ¶
func (f *FileUpload) Path() string
func (*FileUpload) SetVariablePath ¶
func (f *FileUpload) SetVariablePath(variablePath string)
func (*FileUpload) VariablePath ¶
func (f *FileUpload) VariablePath() string
type ResponseContext ¶
func GetResponseContext ¶
func GetResponseContext(ctx context.Context) *ResponseContext
GetResponseContext retrieves the ResponseContext previously injected into ctx via InjectResponseContext. Returns nil if no ResponseContext is present.
func InjectResponseContext ¶
func InjectResponseContext(ctx context.Context) (context.Context, *ResponseContext)
type TraceHTTP ¶
type TraceHTTP struct {
Request TraceHTTPRequest `json:"request"`
Response TraceHTTPResponse `json:"response"`
}