Skip to content

Update mutation removes custom ID field from translated Cypher #95

Closed
@thomas-anderson-bsl

Description

@thomas-anderson-bsl

Since upgrading to version 1.0.0 of the library, I've noticed that the update mutations that we translate to Cypher are not including our custom 'ID' type field in the SET statement. For various reasons, we need to use a separately declared 'ID' field that isn't _id.

The effect of this is that the ID field is dropped from the resulting object in the Neo4j database.

Here's a simplified example based on our current usecase:

Schema:

type Person {
    userId : ID!
    username: String
}

Input GraphQL:

mutation {
    updatePerson(username: $username, userId: $userId) { username userId } 
}

Output Cypher:

MATCH (updateParson:Person { userId: $userId }) SET updatePerson =  { username: $username } WITH updatePerson RETURN updatePerson { .username, .userId } AS updatePerson

Relevant Java translation code:

final GraphQLSchema graphQLSchema = SchemaBuilder.buildSchema(schema);
translator = new Translator(graphQLSchema);
final List<Cypher> cypher = translator.translate(query, variables);

Pre-update Person:

{
    userId: "<SOME USER ID>",
    username: "John.Smith"
}

Post-update Person:

{
    username: "Jeremy.Smith"
}

This used to work correctly in 1.0.0-M03 (see relevant code here), where the userId would correctly be passed through to the resulting Cypher.

In version 1.0.0, the Cypher is built here. It doesn't explicitly exclude the userId field, but I have a feeling that it's related to the fact that it's an ID type field.

This issue could possibly be related to issue 83.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions