Dql traverse reverse query

i wrote a dql query that traverse reverse. but it does not work.

my schema is :

type Content {
    id:ID!
	status: Int
    reviewer_response: String
    title: String
    video: String
    video_time: Int 
    Thumbnail: String
    Form_values: String
    Search_string: String
    publish: Boolean!
    created_at: DateTime
    updated_at: DateTime
}

type Channel {
    id: ID!
	  title: String!
    description: String
    poster: String
    logo: String
    categories: [String]
    publish: Boolean!
    created_at: DateTime
    updated_at: DateTime
    contents: [Content]
    campaigns: [Campaign]
}

my query that not work is here ?

{
  me(func: type(Content)) {
    uid,
    Content.title,
    Content.~contents{
        uid
        title:Channel.title
        publish:Channel.publish
    }
  }
}

whats wrong with my query ?

1 Like

Reverse does not work without adding in DQL @reverse directive in the DQL generated schema. Can you show tue generated DQL schema?

And even then, the ~ should be before the whole predicate. Like: ~Content.contents

1 Like

i fix it with @hasInverse

type Content{
    id:ID!
	  status: Int
    reviewer_response: String
    title: String
    video: String
    video_time: Int 
    Thumbnail: String
    Form_values: String
    Search_string: String
    publish: Boolean!
    createdAt: DateTime!
    updated_at: DateTime
    campaign: Campaign @hasInverse(field:"contents")
    channel: Channel @hasInverse(field:"contents")
}

type Channel {
    id: ID!
	  title: String!
    description: String
    poster: String
    logo: String
    categories: [String]
    publish: Boolean!
    createdAt: DateTime 
    updatedAt: DateTime
    contents: [Content] @hasInverse(field:"channel")
    campaigns: [Campaign]
}

and my dql query

{
  me(func: type(Content)) {
    uid,
    Content.title,
    Content.channel{
        uid
        title:Channel.title
        publish:Channel.publish
    }
  }
}

how fix it with @reverse ?