Skip to content

Instantly share code, notes, and snippets.

Avatar

David Koblas koblas

View GitHub Profile
View wrap_graphql.go
package resolver
import (
"reflect"
"strings"
"github.com/graphql-go/graphql"
"github.com/mitchellh/mapstructure"
"gopkg.in/asaskevich/govalidator.v4"
)
@koblas
koblas / login.ts
Created Aug 7, 2019
Login Typescript
View login.ts
export interface AuthTokenResponse {
token?: string;
created?: boolean;
user?: UserType;
errors?: ValidationError[];
}
// tslint:disable:no-multiline-string
const LOGIN_MUTATION = gql`
@koblas
koblas / fail.json
Created Aug 29, 2018
failing alexa response
View fail.json
{
"version": "1.0",
"sessionAttributes": {
"Counter": 1,
"QuizAnswer": "Jefferson City",
"QuizItemIndex": 24,
"QuizProperty": "Capital",
"QuizScore": 0,
"State": 1
},
View simple_example.go
func init() {
mutationConfig.AddFieldConfig("sentimentAnalysis", &graphql.Field{
Type: graphql.NewObject(graphql.ObjectConfig{
Name: "SentimentAnalysisResult",
Description: "Sentiment Analysis Response",
Fields: graphql.Fields{
"score": &graphql.Field{
Type: graphql.Int,
},
},
View user_update.go
package nresolver
import (
"context"
"github.com/graphql-go/graphql"
"github.com/koblas/projectx/server-go/pkg/contextkey"
"github.com/koblas/projectx/server-go/pkg/model"
"github.com/koblas/projectx/server-go/pkg/service"
)
@koblas
koblas / schema.go
Created Aug 3, 2018
GraphQL Scheme base
View schema.go
package nresolver
import (
"github.com/graphql-go/graphql"
)
var queryConfig = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
// Must initialize to an empty set
Fields: graphql.Fields{},
@koblas
koblas / wrap_isauth.go
Created Aug 3, 2018
graphql authentication wrapper
View wrap_isauth.go
package nresolver
import (
"errors"
"github.com/graphql-go/graphql"
"github.com/koblas/projectx/server-go/pkg/contextkey"
"github.com/koblas/projectx/server-go/pkg/service"
)
@koblas
koblas / wrap_graphql.go
Last active Aug 3, 2018
graphql-go/graphql wrapper for unmarshaling
View wrap_graphql.go
package nresolver
import (
"reflect"
"strings"
"github.com/asaskevich/govalidator"
"github.com/graphql-go/graphql"
"github.com/mitchellh/mapstructure"
)
@koblas
koblas / user_service.go
Created Jul 30, 2018
GraphQL user_update code separation
View user_service.go
// UpdateUser save user updates to the DB
func (svc *userService) UpdateUser(ctx context.Context, user *model.User, args UpdateUserInput) (*model.User, error) {
update := make(map[string]interface{})
if args.Password != nil {
user.HashPassword(*args.Password)
update["password"] = user.Password
}
if args.Name != nil && *args.Name != user.Name {
update["name"] = *args.Name
@koblas
koblas / openvpn.cf
Created Mar 28, 2017
OpenVPN Cloudformation template
View openvpn.cf
{
"Description": "EC2 OpenVPN host for stage-railz",
"Mappings": {
"AmiMap": {
"us-east-1": {
"bastion": "ami-2757f631",
"ecs": "ami-b2df2ca4",
"ubuntu1604": "ami-2757f631"
},
"us-west-2": {