0

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:

  1. supplying an empty array [] for the tags field in the mutation but I fail to make that work. I still get the error.
  2. 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

1
  • Hi, could you add your current @neo4j/graphql version? This could be a bug in that library. Commented Mar 1, 2022 at 10:58

1 Answer 1

2

IIRC, this was a bug that was fixed in 2.5.3. I've just tried the Mutation and input given above with the code for the current 3.0.1 release, and everything seems to be working as expected.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for that. That indeed was the culprit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.