Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Gufran Mirza gufranmirza

🏠
Working from home
View GitHub Profile
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 {
View main.go
package main
import (
"fmt"
"time"
)
func main() {
fmt.Println("main execution started")
You can’t perform that action at this time.