Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // NewRequest makes a new request to send to some graphql response NewRequest() Request // AddRequestModifier adds a request modifier to the client, use this to add headers or do some retry logic SetTransport(transport Transport) Client }
Client represents a GraphQL client
type GqlMarshaler ¶
GqlMarshaler implements a way to Marshal to a graphql request. This returns a list of QueryParts to add to the parent part of the graphql API.
type Marshaler ¶
type Marshaler struct { IdentLevel int // contains filtered or unexported fields }
Marshaler marshels the object to a graphql request
func Marshal ¶
Marshal will start the marshalling process and convert the object to a graphql request
func (*Marshaler) MarshalToGraphql ¶
MarshalToGraphql takes the object and returns a new graphql query
type QueryPart ¶
type QueryPart struct { // Value is the name of the field that graphql needs Value string // Arguments are the arguments that this field can take this maps args to the Graphql type Arguments map[string]string // Subfield represents other fields, for example in a bigger queries SubFields []*QueryPart // contains filtered or unexported fields }
QueryPart Represents a part of a graphql query
type Request ¶
type Request interface { // SetTransport sets the transport for the request when send SetTransport(transport Transport) Request //WithVariable adds a variable to the request WithVariable(name string, value interface{}) Request // Query sets the request to a query. It will take the interface and perform reflection to see // what fields to request from graphql. The fields should be json serializable (that this // Respects the json tags) or you could use the graphql tags for more specific uses Query(object interface{}) Request // Mutation sets the request to a mutation. It will take the interface and perform reflection to see // what fields to request from graphql. The fields should be json serializable (that this // Respects the json tags) or you could use the graphql tags for more specific uses Mutation(object interface{}) Request // Send sends the request to the graphql API. This returns a filled out version of the interface passed // into query or mutation methods Send() (Response, error) // GetQuery gets the full query GetQuery() string //GetVariables gets the variables for the request GetVariables() map[string]interface{} //GetInterface gets the interface that the response should adhere to GetInterface() interface{} }
Request represents a graphql request to some API
type Response ¶
type Response struct { // HttpResponse gets the header off the response HttpResponse *http.Response // Payload is the raw payload Payload []byte // obj is the object to unserialize Response interface{} // HttpRequest is the raw Request HttpRequest *http.Request }
Response represents a response from a graphql api
type SimpleHTTPTransport ¶
type SimpleHTTPTransport struct {
// contains filtered or unexported fields
}
SimpleHTTPTransport is a simple http api that allows you to make a single request to headers get the response from the API.
func NewSimpleHTTPTransport ¶
func NewSimpleHTTPTransport(apiURL string) *SimpleHTTPTransport
NewSimpleHTTPTransport takes the api URL and then returns a SimpleHttpTransport
func (*SimpleHTTPTransport) AddHeader ¶
func (s *SimpleHTTPTransport) AddHeader(name string, value string)
AddHeader adds a header onto therequest object