neo4j / graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
https://neo4j.com/docs/graphql-manual/current/
Apache License 2.0
497 stars 147 forks source link

@cypher directive eats up input parameters when they are equal #5467

Closed mobsean closed 1 month ago

mobsean commented 1 month ago

Describe the bug This only occours when the input parameter of custom @cypher directive are the same. very strange one.

Type definitions

    type Test {
        name: String!
        groups: [String!]
    }

    type Mutation {
        mergeTest(
            name: String!, 
            groups: [String!]
        ): Test
        @cypher( statement: """ 
            MERGE (t:Test {name: $name}) SET t.groups = $groups
            return t
        """
        , columnName: "t"
        )
    }

To Reproduce Steps to reproduce the behavior:

  1. Run a server with typeDefs above
  2. Execute the following Mutation...
mutation(
  $name: String!
  $groups: [String!]
){
  mergeTest(name: $name, groups: $groups)
  {
    name
    groups
  }
}

with these variables:

{
  "name": "test",
  "groups": ["test1"]
}

this produces following debug output:

  @neo4j/graphql:execution executing cypher +5m
  @neo4j/graphql:execution CALL {
  @neo4j/graphql:execution     MERGE (t:Test {name: $param0}) SET t.groups = $param1
  @neo4j/graphql:execution     return t
  @neo4j/graphql:execution }
  @neo4j/graphql:execution WITH t AS this0
  @neo4j/graphql:execution WITH this0 { .name, .groups } AS this0  
  @neo4j/graphql:execution RETURN this0 AS this +0ms
  @neo4j/graphql:execution cypher params: { param0: 'test', param1: [ 'test1' ] } +2ms
  @neo4j/graphql:execution Execute successful, received 1 records +5m

everything is fine.

  1. now only change input variables to this and consider that the strings are the same :
{
  "name": "test",
  "groups": ["test"]
}

the produced debug output is

  @neo4j/graphql:execution executing cypher +2m
  @neo4j/graphql:execution CALL {
  @neo4j/graphql:execution     MERGE (t:Test {name: $param0}) SET t.groups = $param0   <---- $param1 is gone
  @neo4j/graphql:execution     return t
  @neo4j/graphql:execution }
  @neo4j/graphql:execution WITH t AS this0
  @neo4j/graphql:execution WITH this0 { .name, .groups } AS this0  
  @neo4j/graphql:execution RETURN this0 AS this +0ms
  @neo4j/graphql:execution cypher params: { param0: 'test' } +1ms  <---- $param1 is gone
  @neo4j/graphql:execution Execute successful, received 1 records +2m

$param1 is gone. 🤯

  1. See error
{
  "errors": [
    {
      "message": "Expected Iterable, but did not find one for field \"Test.groups\".",
      "locations": [
        {
          "line": 8,
          "column": 5
        }
      ],
      "path": [
        "mergeTest",
        "groups"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "GraphQLError: Expected Iterable, but did not find one for field \"Test.groups\".",

this is clear, because we´re expecting groups to be an array of string.

Expected behavior

Input parameters should be allowed to the same string.

System (please complete the following information):

Additional context

this is another one that already was working in Version 3.x.x of this lib...

neo4j-team-graphql commented 1 month ago

Many thanks for raising this bug report @mobsean. :bug: We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! :pray:

neo4j-team-graphql commented 1 month ago

We've been able to confirm this bug using the steps to reproduce that you provided - many thanks @mobsean! :pray: We will now prioritise the bug and address it appropriately.