Mutation for relationship with objects as arguments


I have a mutation createaAccess that creates a HAS_ACCESS_TO relationship between 2 nodes. This works fine.

  createaAccess(user: ID!, entity_role: [String]!,  application_role: [String]!, entity: Int!): WorkstationUser 
        MATCH (from:WorkstationUser {id: $user})
        MATCH (to {id: $entity})
        SET to:Entity
        MERGE (from)-[:HAS_ACCESS_TO {application_role: $application_role, entity_role: $entity_role} ]->(to)
        RETURN from

I was wondering if there was a way to send user Object instead of id? One of the Apollo graphql tutorial says it can be done. Ref

But If I change the mutation schema to

 createaAccess(user: WorkstationUser!, entity_role: [String]!, .... 

It gives me validation error when parsing schema on load itself.

[nodemon] starting `node src/index.js`
    throw new Error( (error) {

Error: The type of Mutation.createaAccess(user:) must be Input Type but got: WorkstationUser!.
    at assertValidSchema (D:\graphqlws\graphql-graphdb\node_modules\graphql\type\validate.js:80:11)

Yes that should work, but you'll need to declare an input type in your GraphQL type definitions to use for the argument:

input WorkstationUserInput {
  id: ID!
  name: String

then your mutation is something like this, where the input type becomes an object Cypher parameter:

createAccess(user: WorkstationUserInput, ...): WorkstationUser @cypher(statement:
   MATCH (from:WorkstationUser {id: $})