Documentation ¶
Overview ¶
Package graphql provides a GraphQL client to the Spectator Rails API.
Index ¶
- Variables
- func Base64Image(url, mimeType string) string
- func CreateStore()
- func GeneratePassword() string
- func PublicationTime(volume, issue int) (datetime string)
- func RunGraphqlQuery(req *graphql.Request, resp interface{}) error
- func SectionIDByName(name string) (id int, found bool)
- func UserIDByFirstLastName(first, last string) (id int, err error)
- type AllSectionsResponse
- type Article
- type ArticleByContentResponse
- type CreateArticleResponse
- type CreateMediumResponse
- type CreateUserResponse
- type Medium
- type Section
- type User
- type UserByFirstLastNameResponse
Constants ¶
This section is empty.
Variables ¶
var IssueDates = map[int]map[int]string{ 105: map[int]string{ 13: "2015-04-17", 14: "2015-05-06", }, 106: map[int]string{ 3: "2015-10-16", 4: "2015-10-30", 6: "2015-12-02", }, 107: map[int]string{ 1: "2017-09-09", 2: "2017-09-30", 3: "2016-10-17", 11: "2017-03-10", 12: "2017-03-31", 13: "2017-04-21", 14: "2017-05-08", 15: "2017-05-26", 16: "2017-06-09", }, 108: map[int]string{ 1: "2017-09-11", 2: "2017-09-29", 3: "2017-10-17", 4: "2017-10-31", 5: "2017-11-10", 6: "2017-12-01", 7: "2017-12-20", 8: "2018-01-19", 9: "2018-02-02", 10: "2018-02-15", 11: "2018-03-19", 12: "2018-03-29", 13: "2018-04-20", 14: "2018-05-04", 15: "2018-05-25", 16: "2018-06-08", }, }
var Sections []Section
Sections is a slice of all the sections.
Functions ¶
func Base64Image ¶
Base64Image returns the base 64 encoding of an image at a URL.
func CreateStore ¶
func CreateStore()
CreateStore creates a store for commonly accessed information (e.g. all sections, all roles).
func GeneratePassword ¶
func GeneratePassword() string
GeneratePassword creates a random alphanumeric, 16-letter password.
func PublicationTime ¶
PublicationTime returns the datetime for an article of a volume and issue. It uses the day the article was printed and distributed as the date and the current time as the time.
func RunGraphqlQuery ¶
func RunGraphqlQuery(req *graphql.Request, resp interface{}) error
RunGraphqlQuery takes a GraphQL request and executes it. It pours the response into a given address.
func SectionIDByName ¶
SectionIDByName returns a section's ID by its name.
func UserIDByFirstLastName ¶
UserIDByFirstLastName returns a user's ID by his or her first and last names.
Types ¶
type AllSectionsResponse ¶
type AllSectionsResponse struct {
AllSections []Section
}
AllSectionsResponse is a structure to unmarshall the JSON of an allSections query.
type Article ¶
type Article struct { ID string Slug string // We create articles with summaries, but article records initiate themselves // with Previews. This resolves the many problems with simply using article // focus sentences as previews on the website (if focus sentences are empty, // Rails can generate a Preview using the article's content). Preview string }
Article represents an article.
func ArticleByContent ¶
ArticleByContent gets an article by its content. This function is mainly used to determine if an article exists already.
func CreateArticle ¶
CreateArticle constructs a GraphQL mutation and creates an article. It returns an error if any is encountered.
type ArticleByContentResponse ¶
type ArticleByContentResponse struct {
ArticleByContent Article
}
ArticleByContentResponse is a structure to unmarshall the JSON of an articleByContent query.
type CreateArticleResponse ¶
type CreateArticleResponse struct {
CreateArticle Article
}
CreateArticleResponse is a structure to unmarshall the JSON of a createArticle mutation.
type CreateMediumResponse ¶
type CreateMediumResponse struct {
CreateMedium Medium
}
CreateMediumResponse is a structure to unmarshall the JSON of a createMedium mutation.
type CreateUserResponse ¶
type CreateUserResponse struct {
CreateUser User
}
CreateUserResponse is a structure to unmarshall the JSON of a createUser mutation.
type Medium ¶
type Medium struct {
ID, Title, AttachmentUrl string
}
Medium represents an illustration or photograph.
type Section ¶
Section represents a department/section of the newspaper.
func AllSections ¶
func AllSections() []Section
AllSections creates an allSections GraphQL query. It returns the resulting sections.
type User ¶
User represents a contributor, illustrator, or photographer.
func CreateUser ¶
CreateUser constructs a GraphQL mutation and creates a user. It returns an error if any is encountered.
type UserByFirstLastNameResponse ¶
type UserByFirstLastNameResponse struct {
UserByFirstLastName User
}
UserByFirstLastNameResponse is a structure to unmarshall the JSON of an userByFirstLastName query.