Skip to content

Instantly share code, notes, and snippets.

@gufranmirza
Created August 11, 2019 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gufranmirza/0ddd193b124a689dd900d8cec4c79f9f to your computer and use it in GitHub Desktop.
Save gufranmirza/0ddd193b124a689dd900d8cec4c79f9f to your computer and use it in GitHub Desktop.
"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{
Type: graphql.NewNonNull(graphql.String),
},
"duration": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
var song Song
song.ID = params.Args["id"].(string)
song.Album = params.Args["album"].(string)
song.Title = params.Args["title"].(string)
song.Duration = params.Args["duration"].(string)
songs = append(songs, song)
return song, nil
},
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment