graphql

package
v1.0.1-0...-6123b81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2018 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

Package graphql provides a GraphQL client to the Spectator Rails API.

Index

Constants

This section is empty.

Variables

View Source
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",
	},
}
View Source
var Sections []Section

Sections is a slice of all the sections.

Functions

func Base64Image

func Base64Image(url, mimeType string) string

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

func PublicationTime(volume, issue int) (datetime string)

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

func SectionIDByName(name string) (id int, found bool)

SectionIDByName returns a section's ID by its name.

func UserIDByFirstLastName

func UserIDByFirstLastName(first, last string) (id int, err error)

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

func ArticleByContent(content string) (article Article, found bool)

ArticleByContent gets an article by its content. This function is mainly used to determine if an article exists already.

func CreateArticle

func CreateArticle(attrs map[string]interface{}) (article Article, err error)

CreateArticle constructs a GraphQL mutation and creates an article. It returns an error if any is encountered.

func (Article) String

func (a Article) String() string

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.

func CreateMedium

func CreateMedium(attrs map[string]string) (medium Medium, err error)

CreateMedium constructs a GraphQL mutation and creates a type of media. It returns an error if any is encountered.

type Section

type Section struct {
	ID        string
	Name      string
	Slug      string
	Parent_ID string
}

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

type User struct {
	ID        string
	FirstName string
	LastName  string
	Email     string
}

User represents a contributor, illustrator, or photographer.

func CreateUser

func CreateUser(first, last string) (user User, err error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL