30
loading...
This website collects cookies to deliver better user experience
{
user {
name
id
dateofbirth
}
}
Returns:
{
"data": {
"user": {
"name": "Name 1",
"id": "uniqueid124",
"dateofbirth" : "23/10/1995"
}
}
}
{
allusers(name: "nam") {
name
dateofbirth
}
}
Returns:
{
"data": {
"allusers": [{
"name" : "name lastname",
"dateofbirth": "23/03/1997"
}. {
"name" : "name middlename",
"dateofbirth": "03/07/2003"
}]
}
}
{
mostViewedBlog: blog(id: "1234") {
...blogFields
}
mostRecentBlog: blog(id: "43243") {
...blogFields
}
relatedBlog: blog(idL "323") {
...blogFields
}
}
fragment blogFields on Blog {
name
description
image_url
}
on
keyword defines on which fields you are going to use the fragment. GraphQL then allows to define those fragments on those fields which prevent errors and making sure that fragment fields are present.:
. Those are aliases and you can use them to rename the result of the fieldResult:
{
"data": {
"mostViewedBlog" : {
"name": "GraphQL Queries",
"description" : "Description of GraphQL Queries",
"image_url": "blogimage.png"
},
"mostRecentBlog" : {
"name": "What is GraphQL",
"description" : "Description of GraphQL",
"image_url": "blogimage.png"
},
"relatedBlog" : {
"name": "GraphQL Mutation",
"description" : "Description of GraphQL Mutation",
"image_url": "blogimage.png"
}
}
}
30