22 lines
511 B
Go
22 lines
511 B
Go
package serverapi
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"go.jolheiser.com/gql"
|
|
)
|
|
|
|
// GraphQL returns a gql.Client for a ServerAPI instance
|
|
func (c *Client) GraphQL() *gql.Client {
|
|
return gql.NewClient(fmt.Sprintf("%s/graphql", c.Endpoint), &gql.ClientOptions{
|
|
HTTP: c.Options.HTTP,
|
|
})
|
|
}
|
|
|
|
// GraphQLRequest returns a pre-filled gql.Request with the password set
|
|
func (c *Client) GraphQLRequest(query string) *gql.Request {
|
|
req := gql.NewRequest(query)
|
|
req.Header.Add("X-ServerAPI-Password", c.Options.Password)
|
|
return req
|
|
}
|