Documentation ¶
Index ¶
- func HasAuthError(errors []ResponseError) bool
- type Client
- type ErrorCode
- type JSONRequest
- type Message
- type MessageType
- type MultipartWriterRequest
- func (m *MultipartWriterRequest) ContentType() string
- func (m *MultipartWriterRequest) CreateFormFile(fieldname, filename string, reader io.Reader) error
- func (m *MultipartWriterRequest) GetReader() io.Reader
- func (m *MultipartWriterRequest) String() string
- func (m *MultipartWriterRequest) Write(data []byte) (int, error)
- type Request
- type RequestInterface
- type Response
- type ResponseError
- type TaskMonitor
- type Upload
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasAuthError ¶
func HasAuthError(errors []ResponseError) bool
Types ¶
type Client ¶
type Client struct { URL string `yaml:"url"` UserInfo *UserInfo `yaml:"user_info"` // AllowInsecure set whether to check the server certificates AllowInsecure bool // Dialer dial websocket connecting to graphql server for subscription. // If nil, websocket.DefaultDialer will be used. Dialer *websocket.Dialer // HTTPClient dial http connecting to graphql server for query. // If nil, http.DefaultClient will be used. HTTPClient *http.Client // If set, mutation will wait task down. TaskMonitor TaskMonitor // contains filtered or unexported fields }
type ErrorCode ¶
type ErrorCode string
const ( PermissionDenied ErrorCode = "PERMISSION_DENIED" LoginFailed ErrorCode = "LOGIN_FAILED" UserNotFound ErrorCode = "USER_NOT_FOUND" UserPasswordIncorrect ErrorCode = "USER_PASSWORD_INCORRECT" NotMatchUser ErrorCode = "NOT_MATCH_USER" LoadTokenFailed ErrorCode = "LOAD_TOKEN_FAILED" // #nosec WebsocketConnectError ErrorCode = "WEBSOCKET_CONNECT_ERROR" )
type JSONRequest ¶
type JSONRequest []byte
func (JSONRequest) ContentType ¶
func (r JSONRequest) ContentType() string
func (JSONRequest) GetReader ¶
func (r JSONRequest) GetReader() io.Reader
func (JSONRequest) String ¶
func (r JSONRequest) String() string
type Message ¶
type Message struct { ID string `json:"id,omitempty"` Type MessageType `json:"type"` PayLoad json.RawMessage `json:"payload,omitempty"` }
Message is the request/response type when use the websocket connection
type MessageType ¶
type MessageType string
const ( ConnectionInitMsg MessageType = "connection_init" // Client -> Server ConnectionTerminateMsg MessageType = "connection_terminate" // Client -> Server StartMsg MessageType = "start" // Client -> Server StopMsg MessageType = "stop" // Client -> Server ConnectionAckMsg MessageType = "connection_ack" // Server -> Client ConnectionErrorMsg MessageType = "connection_error" // Server -> Client DataMsg MessageType = "data" // Server -> Client ErrorMsg MessageType = "error" // Server -> Client CompleteMsg MessageType = "complete" // Server -> Client ConnectionKeepAliveMsg MessageType = "ka" // Server -> Client )
type MultipartWriterRequest ¶
MultipartWriterRequest generates multipart messages as RequestInterface, it wraps multipart writer. But differently, you can CreateFormFile with file reader directly.
func NewMultipartWriterRequest ¶
func NewMultipartWriterRequest() *MultipartWriterRequest
NewMultipartWriterRequest returns a new MultipartWriterRequest
func (*MultipartWriterRequest) ContentType ¶
func (m *MultipartWriterRequest) ContentType() string
func (*MultipartWriterRequest) CreateFormFile ¶
func (m *MultipartWriterRequest) CreateFormFile(fieldname, filename string, reader io.Reader) error
func (*MultipartWriterRequest) GetReader ¶
func (m *MultipartWriterRequest) GetReader() io.Reader
func (*MultipartWriterRequest) String ¶
func (m *MultipartWriterRequest) String() string
type RequestInterface ¶
type RequestInterface interface { String() string // humanreadable string GetReader() io.Reader // request body reader ContentType() string // content-type in header }
RequestInterface provides metadata of a http request
func EncodeRequest ¶
func EncodeRequest(req *Request) (RequestInterface, error)
EncodeRequest encode graphql request to http request. If req contains an upload file, it encode message as multipart/form-data, and the file will not be copied
type Response ¶
type Response struct { Data json.RawMessage `json:"data"` Errors []ResponseError `json:"errors,omitempty"` }
type ResponseError ¶
type ResponseError struct { Message string `json:"message"` Code ErrorCode `json:"code,omitempty"` }
func (ResponseError) Error ¶
func (e ResponseError) Error() string
func (*ResponseError) UnmarshalJSON ¶
func (e *ResponseError) UnmarshalJSON(data []byte) error
type TaskMonitor ¶
type Upload ¶
Upload scalar to add support for GraphQL multipart requests
func (*Upload) MarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.