graphql-compose / graphql-compose-relay

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

not working?

tanekim88 opened this issue · comments

const userLogin = new Resolver({
  name: 'userLoginOne',
  type: ViewerOutputTC,
  args: {
    username: 'String!',
    password: 'String!',
  },
  resolve: async ({
    source,
    args: {
      input: { username, password },
    },
    context,
    info,
  }) => {
    const { ctx, redis } = context;
    const user = await User.findOne({ username });

    return { viewer: user };
  },
});







const UserSchema = new Schema(
  {
   username: {
      type: String,
      unique: true,
    },
    password: {
      type: String,
    },
  }
);

export const User = model<any>(names.user, UserSchema);
let UserMongooseTC = composeWithMongoose(User, {});
const UserMongooseTC = UserMongooseTC .addResolver(userLogin);
const UserTC= composeWithRelay(UserMongooseTC ) ;

then why this is not working? It only accepts username and password, not input.


mutation {
   userLogin(input:{username:'1',password:'1'}){
        email
   }
}

You need to mark resolvrs as mutation:

const userLogin = new Resolver({
  name: 'userLoginOne',
  kind: 'mutation', // <------------- here
  type: ViewerOutputTC,
  args: {