Comparsion of ToJSON vs JSON encoding of protocol buffer for the query in query_test.go
{
me(_uid_:0x01) {
name
gender
status
friend {
name
}
}
}
ToJSON -
{
"_root_":[
{
"_uid_":"0x1",
"friend":[
{
"_uid_":"0x17",
"name":"Rick Grimes"
},
{
"_uid_":"0x18",
"name":"Glenn Rhee"
},
{
"_uid_":"0x19",
"name":"Daryl Dixon"
},
{
"_uid_":"0x1f",
"name":"Andrea"
},
{
"_uid_":"0x65"
}
],
"gender":"female",
"name":"Michonne",
"status":"alive"
}
]
}
JSON encoding of Protocol buffer
{
"uid":"1",
"attribute":"_root_",
"properties":[
{
"prop":"name",
"val":"TWljaG9ubmU="
},
{
"prop":"gender",
"val":"ZmVtYWxl"
},
{
"prop":"status",
"val":"YWxpdmU="
}
],
"children":[
{
"uid":"23",
"attribute":"friend",
"properties":[
{
"prop":"name",
"val":"UmljayBHcmltZXM="
}
]
},
{
"uid":"24",
"attribute":"friend",
"properties":[
{
"prop":"name",
"val":"R2xlbm4gUmhlZQ=="
}
]
},
{
"uid":"25",
"attribute":"friend",
"properties":[
{
"prop":"name",
"val":"RGFyeWwgRGl4b24="
}
]
},
{
"uid":"31",
"attribute":"friend",
"properties":[
{
"prop":"name",
"val":"QW5kcmVh"
}
]
},
{
"uid":"101",
"attribute":"friend",
"properties":[
{
"prop":"name",
"val":""
}
]
}
]
}
Ignore that the val
are base64 encoded. The main point is that the schema of GraphQL isn’t retained.