Categorygithub.com/icco/graphql
modulepackage
0.0.0-20231225210641-d87ace733e3b
Repository: https://github.com/icco/graphql.git
Documentation: pkg.go.dev

# README

graphql.natwelch.com

A new backend for graphql.natwelch.com.

Build Status Go Report Card Go Reference

The next iteration in Nat's content management system. Previous versions include:

Install

This repo requires Go 1.11 to be installed.

  1. Start postgres on your local machine with a database called writing.
  2. Copy local.env to .env
  3. env $(cat .env) go run -v ./server to start the server.
  4. Visit http://localhost:8080/ which has a default graphql client.

Example Env

DATABASE_URL=postgres://localhost/writing?sslmode=disable&binary_parameters=yes
SESSION_SECRET="random string"
OAUTH2_CLIENTID=something.apps.googleusercontent.com
OAUTH2_SECRET=1234567890
OAUTH2_REDIRECT=http://localhost:8080/callback
PORT=9393

Auth

This uses Auth0 to generate logins. To save yourself setting up the Auth0, you can generate an API key for testing by creating a user. To create a user for testing, run the following insert SQL:

INSERT INTO users (id, role, created_at, modified_at) VALUES ('test', 'admin', now(), now());

Then get your API key:

SELECT apikey from users where id = 'test';

And then set that as the value of the X-API-AUTH on all of your requests to graphql.

Design

This site is hosted at https://graphql.natwelch.com. It runs out of a docker container on Google Kubernetes. It has a postgres backend. This started as a rewrite of a previous project, natnatnat. Its readme walks through a lot of the previous inspiration.

We use https://github.com/99designs/gqlgen to generate a lot of the files.

Documentation

# Packages

No description provided by the author

# Functions

AllComments returns all comments orderd by time.
AllTags returns all tags used in all posts.
Drafts is a simple wrapper around Posts that does return drafts.
FuturePosts returns some posts that are in the future.
GenerateSocialImage creates a static image URL for a post.
GeoConvertValue is used for marshaling data to a database.
GeoFromOrb creates a Geo from github.com/paulmach/orb.Point.
GeoScanner is used for unmarshaling data from a database row.
GetBooks returns all books from the database.
GetComment returns a single comment by ID.
GetLinkByID gets a link by id from the database.
GetLinkByURI gets a link by uri from the database.
GetLinks returns all links from the database.
GetLog gets a single Log by ID.
GetMaxID returns the greatest post ID in the database.
GetPost gets a post by ID from the database.
GetPostString gets a post by an ID string.
GetRandomPosts returns a random selection of posts.
GetStat returns the history of a stat.
GetStats returns the limit of the most recently updated stats.
GetTweet returns a single tweet by id.
GetTweets returns an array of tweets from the database.
GetTweetsByScreenName returns an array of tweets from the database filtered by screenname.
GetUser returns a user from the database.
GetUserByAPIKey returns a user from the database.
GetUserFromContext finds the user from the context.
InitDB creates a package global db connection from a database string.
Markdown generator.
New returns a Config that has all of the proper settings for this graphql server.
NewCache creates a new cache.
NewDuration creates a new Duration.
NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface.
NewURI creates a URI from a string.
ParseDurationFromDuration takes a stdlib Duration and turns it into our duration.
ParseDurationFromString takes a duration string and turns it into a duration.
ParseLimit turns a limit and applies defaults into a pair of ints.
ParseTags returns a list of all hashtags currently in a post.
PostComments returns comments for a post ID.
Posts returns some posts.
PostsByTag returns all posts with a tag.
Search searches for posts that have matching titles, content or tags.
SummarizeText takes a chunk of markdown and just returns the first paragraph.
UserLogs gets all logs for a User.
UserPhotos gets all photos for a User.
WithUser puts a user in the context.

# Constants

AppName is the name of the service in GCP.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
StorageBucketName is the bucket name we are uploading to.

# Variables

No description provided by the author
No description provided by the author
HashtagRegex is a regex for finding hashtags in Markdown.
TwitterHandleRegex is a regex for finding @username in Markdown.

# Structs

No description provided by the author
Book is a book on Goodreads.
Cache is a basic type as defined by gqlgen.
Comment is a comment on a post.
No description provided by the author
No description provided by the author
No description provided by the author
Duration is a float64 representation of a Duration in seconds.
No description provided by the author
No description provided by the author
Geo is a simple type for wrapping a point.
No description provided by the author
No description provided by the author
Link is a link I have save on pinboard or a link in a post.
A Log is a journal entry by an individual.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Photo represents an uploaded photo.
Post
Post is our representation of a post in the database.
Resolver is the type that gqlgen expects to exist.
A stat is a key value pair of two interesting strings.
A Tweet is an archived tweet.
TwitterURL is a representation of data from cacophony.
URI is a string representation of a URI.
User is a database object based off of what we get back from Google OAuth.

# Interfaces

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author