Hi, need help figuring out how to do a DQL mutation that is equivalent to the example below.
Given GraphQL types:
type Blog {
title: String
tagged: [Tag] @hasInverse(field: blogs)
}
type Tag {
id: ID!
tag_name: String
blogs: [Blog]
}
By doing a mutation as follows:
mutation ($input: [AddBlogInput!]!) {
addBlog(input: $input) {
blog {
title
tagged {
tag_name
}
}
}
}
Mutation input:
{
"input": [
{
"title": "DQL fundamentals",
"tagged": [{
"tag_name": "technical"
},{
"tag_name": "beginner"
}]
},
{
"title": "Advanced DQL",
"tagged": [{
"tag_name": "technical"
},{
"tag_name": "intermediate"
}]
}
]
}
When I query by Blog
type:
{
blogs(func: type(Blog)) {
uid
Blog.title
Blog.tagged {
Tag.tag_name
}
}
}
Result of query by Blog
type:
{
"data": {
"blogs": [
{
"uid": "0x704e2",
"Blog.title": "DQL fundamentals",
"Blog.tagged": [
{
"Tag.tag_name": "technical"
},
{
"Tag.tag_name": "beginner"
}
]
},
{
"uid": "0x704e5",
"Blog.title": "Advanced DQL",
"Blog.tagged": [
{
"Tag.tag_name": "technical"
},
{
"Tag.tag_name": "intermediate"
}
]
}
]
}
}
Query by Tag
type:
{
tags(func: type(Tag)) {
uid
Tag.tag_name
Tag.blogs {
Blog.title
}
}
}
Result of query by Tag
type:
{
"data": {
"tags": [
{
"uid": "0x704e1",
"Tag.tag_name": "technical",
"Tag.blogs": [
{
"Blog.title": "DQL fundamentals"
}
]
},
{
"uid": "0x704e3",
"Tag.tag_name": "beginner",
"Tag.blogs": [
{
"Blog.title": "DQL fundamentals"
}
]
},
{
"uid": "0x704e4",
"Tag.tag_name": "technical",
"Tag.blogs": [
{
"Blog.title": "Advanced DQL"
}
]
},
{
"uid": "0x704e6",
"Tag.tag_name": "intermediate",
"Tag.blogs": [
{
"Blog.title": "Advanced DQL"
}
]
}
]
}
}
Question: How to write the mutation in DQL that will yield the same results as above?