Is graphQL implemented differently in FaunaDB

I have found graphQL to work straight of the bat with this schema

type Comment {
comment: String
subscriber: Subscriber
blog: Blog @relation
likes: Int
}
type Blog {
title: String
likes: Int
author: Author! @relation
comments: [Comment!] @relation
}


{
comments {
_id
title
blog {
title
}
}
}

But FaunaDB GraphQL doesnt support this until we provide a query in the schema

query findCommentByID($id: ID!) {
findCommentByID(id: $id) {
_id
comment
blog {
title
}
}
}

My other question was how to implement something like findAllCommentsByBlogId

There is of course a workaround for findAllCommentsByBlogId
Simply write a findBlogByBlogId, then include the comments of that blog.

Something in the vein of (didnt test the code):

query findBlogByID(id: ID!): [Blog!]!

then call as follows:

 query SomeQueryName{
    findBlogByID(_size: 6, id: <your id>){
      data {
        comments{ 
            data {
                comment
            }
        }
     }
  }
}
1 Like