Node, Express and Graphql environment user system

Asked

Viewed 61 times

-1

Hello, world! I’m studying Graphql and I’m having a problem with this Mutation...

var schema = buildSchema(' type userAccount { firstName: String! lastName: String! mobileNumber: String email: String password: String! } type Mutation { createAccount( firstName: String!, lastName: String!, mobileNumber: String, email: String, password: String! ): userAccount } '); var root = { createAccount: ({firstName, lastName, mobileNumber, email, password}) => { // AccountModel.create é um model do sequelize que registra os dados, isso funciona, mas a mutation retorna null AccountModel.create({ firstName, lastName, mobileNumber, email, password }) } };

// Then in localhost:3000/graphiql I do Mutation and it returns null(I should return the account I just registered) GraphiQL Running nodemon db

1 answer

0

I managed to solve the problem... ... only one Return was missing from the function var root = { createAccount: ({firstName, lastName, mobileNumber, email, password}) => { return AccountModel.create({ firstName, lastName, mobileNumber, email, password }) } };

Browser other questions tagged

You are not signed in. Login or sign up in order to post.