Open tamalsaha opened 4 years ago
Hi @tamalsaha, thanks for looking into the lib.
Could you expand on return the projection of a json object
, could you provide an example of the query your planning to use and the output that you would expect ?
Thanks, @chris-ramon ! Here is an example:
Input
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "busy-dep",
"labels": {
"app": "busy-dep"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "busy-dep"
}
},
"template": {
"metadata": {
"labels": {
"app": "busy-dep"
}
},
"spec": {
"containers": [
{
"image": "busybox",
"command": [
"sleep",
"3600"
],
"imagePullPolicy": "IfNotPresent",
"name": "busybox"
},
{
"image": "ubuntu:18.04",
"command": [
"sleep",
"3600"
],
"imagePullPolicy": "IfNotPresent",
"name": "ubuntu"
}
],
"restartPolicy": "Always"
}
}
}
}
Query
query {
apiVersion
kind
metdata {
name
}
spec {
replicas
}
}
Output
{
"apiVersion": "apps/v1",
"kind": "Deployment",
"metadata": {
"name": "busy-dep",
},
"spec": {
"replicas": 1
}
}
I want to use GraphQL query syntax on nested JSON doc. Is this possible?
graphql can only query fields defined in the object so you cannot add dynamic/undefined fields to a query. You do however have a few options
Is it possible to write a function that can return the projection of a json object via GraphQL query?