Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Gufran Mirza gufranmirza

🏠
Working from home
View GitHub Profile
View mirror.sh
#!/bin/sh
set -eufo pipefail
if [ "$#" -ne 2 ]; then
echo "usage: $0 source_repo_url target_repo_url" >&2
exit 1
fi
SOURCE_URL="$1"
View main.go
package main
import (
"encoding/json"
"net/http"
"log"
"github.com/graphql-go/graphql"
)
View main.go
"createSong": &graphql.Field{
Type: songType,
Args: graphql.FieldConfigArgument{
"id": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
"album": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
"title": &graphql.ArgumentConfig{
View main.go
package main
import (
"encoding/json"
"net/http"
"log"
"github.com/graphql-go/graphql"
)
View main.go
rootQuery := graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"songs": &graphql.Field{
Type: graphql.NewList(songType),
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
return nil, nil
},
},
},
View main.go
albumType := graphql.NewObject(graphql.ObjectConfig{
Name: "Album",
Fields: graphql.Fields{
"id": &graphql.Field{
Type: graphql.String,
},
"artist": &graphql.Field{
Type: graphql.String,
},
"title": &graphql.Field{
View main.go
artistType := graphql.NewObject(graphql.ObjectConfig{
Name: "Artist",
Fields: graphql.Fields{
"id": &graphql.Field{
Type: graphql.String,
},
"name": &graphql.Field{
Type: graphql.String,
},
"type": &graphql.Field{
View main.go
songType := graphql.NewObject(graphql.ObjectConfig{
Name: "Song",
Fields: graphql.Fields{
"id": &graphql.Field{
Type: graphql.String,
},
"album": &graphql.Field{
Type: graphql.String,
},
"title": &graphql.Field{
View main.go
var albums []Album = []Album{
Album{
ID: "ts-fearless",
Artist: "1",
Title: "Fearless",
Year: "2008",
Type: "album",
},
}
View main.go
package main
import (
"encoding/json"
"net/http"
"github.com/graphql-go/graphql"
)
type Album struct {