package serverapi import ( "fmt" "go.jolheiser.com/gql" ) /** This block of type definitions is primarily for easily creating composite structs for GraphQL queries */ // Bans is a list of Ban type Bans []*Ban // Players is a list of Player type Players []*Player // Plugins is a list of Plugin type Plugins []*Plugin // Worlds is a list of World type Worlds []*World // 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.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-Token", c.token) return req }