I am new to graphql and the neo4j graphql library and could use some help.
My aim is to create an optional tags
fields to BlockTitle
I have the following schema:
type BlockTitle {
id: ID! @id
created_at: DateTime! @timestamp
text: String!
tags: [Tag!]! @relationship(type: "HAS_TAG", direction: OUT)
}
type Tag {
id: ID! @id
created_at: DateTime! @timestamp
name: String! @unique
}
in the neo4j graphql docs I red the following:
The relationship at User.posts is considered a "many" relationship. Relationships such as the one above should always be of type NonNullListType and NonNullNamedType, meaning both the array and the type inside of it should have a !.
neo4j doc ref
Honouring the recommendation I made the tags field accordingly: tags: [Tag!]! ...
But I have trouble mutating the following item (with a tag) in apollo studio:
mutation CreateBlockTitles($input: [BlockTitleCreateInput!]!) {
createBlockTitles(input: $input) {
blockTitles {
text
}
}
}
with input
{
"input": {
"text": "A title without a tag"
}
}
which returns following error
"errors": [
{
"message": "BlockTitle.tags required",
"locations": [
{
"line": 2,
"column": 3
}
...
The things I tried / considered:
- supplying an empty array
[]
for the tags field in the mutation but I fail to make that work. I still get the error. - using
[Tag]
instead of[Tag!]!
, but going against the recommended practice. So do not really want to do that.
Thank you for the help <3