neo4j-graphql-js
neo4j-graphql-js copied to clipboard
how to use cypherQuery
Hello, I'm trying to create a query to login a user, the type of my query is the AuthPayload, inside this payload I have the token and the user:
type AuthPayload {
token: String
user: User
}
type User {
uuid: ID!
email: String
password: String
}
this is the query I defined on my server:
login(email: String!, password: String!): AuthPayload @cypher(
statement: """
MATCH (u:User) WHERE u.email = email AND u.password = password RETURN u
"""
)
this is my resolver:
Query: {
login: (parent, args, context, info) => svcUsers.login(parent, args, context, info),
}
this is my service:
login(parent, args, context, info){
let user = null;
const query = cypherQuery(args, context, info);
return {
token: '123',
user: {
email: '123',
password: '321'
}
};
}
and this is the query I'm trying to request:
query login($email: String!, $password: String!) {
login(email: $email, password: $password) {
token,
user {
email
}
}
}
the problem is that I get this error as resopnse: Cannot read property '0' of undefined but if I remove the user from the request:
query login($email: String!, $password: String!) {
login(email: $email, password: $password) {
token
}
}
I can see a correct result with my token....where is the mistake?
many thanks
https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608