MetaMusic is a backend server using GraphQL API.
music
: A user can query/mutate the music- Only title, artist and year are mutable in a
music
. metaData
: A user can add/removemetaData
to/frommusic
- GraphQL.js
- ExpressJS
- DB (POSTGRES)
http://music-lib99.herokuapp.com/ Hosted App URL
Testing can be performed on http://music-lib99.herokuapp.com/graphql
music {
id: string
title: string
album: string
artist: string
year: number
metaData: [{
key: string,
value: string
}]
}
metaData {
key: string
value: string
}
An example query on the above schema would be:
query{
musics{
id
title
album
artist
year
metaData {
key
value
}
}
}
A Query to Get a music
query{
music(musicId:""){
id
title
album
artist
year
metaData{
key
value
}
}
}
Properties responsed are variable according to request parameters.
A Query To mutate data is like
mutation{
(MusicInput:{id:"m4",title:"music4",album:"album4",artist:"artist4",year: 2022,metaData:[{key:"k4",value:"v4"},{key:"k41",value:"k41"}]}){
id
title
.
.
}
}
Queries for getting data ara musics
: to gather all data & music(musicId:"id")
to request a specific data point.
-
addMusic
to add music record to database. -
delMusic(muiscId:"")
to delete a specific data record. -
UpdateTitle(musicId:"",title:"")
,UpdateArtist(musicId:"",atist:"")
andUpdateYear(musicId:"",year:number
for updating mutable records. -
For meta Data
addMeta(musicId:"",key:"",value:"")
for adding meta data to existing music record. -
rmMeta(musicId:"",key:"")
for removing specific meta data record from music database.
For example queries (the demo data contains musicId strings from "m1" to "m4")
query{
music(musicId:"m1")
{
id
title
album
artist
year
metaData{
key
value
}
}
}
This generates following response
{
"data": {
"music": {
"id": "m1",
"title": "Title_string",
"album": "album_string",
"artist": "Himesh",
"year": 1869,
"metaData": [
{
"key": "k1",
"value": "v1"
},
{
"key": "k2",
"value": "v2"
},
{
"key": "k3",
"value": "v3"
}
]
}
}
}