prisma / prisma1

💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]
https://v1.prisma.io/docs/
Apache License 2.0
16.54k stars 861 forks source link

mutations defaults to values defined in datamodel.graphql even after explicit writting otherwise inside resolver #1796

Closed johhansantana closed 6 years ago

johhansantana commented 6 years ago

Bug Report

I have in my datamodel.graphql the following for an User model: role: UserRole! @default(value: "CITIZEN")

The UserRole is:

enum UserRole {
  ADMIN
  DRIVER
  CITIZEN
}

in schema.graphl: createDriver(data: UserCreateInput!): User!

and in the resolver:

return await ctx.db.mutation.createUser(
  {
    data: {
      email: args.data.email,
      password: args.data.password,
      role: "DRIVER"
    }
  },
  info
);

Current behavior When I try to explicit set, in this example, an user role to DRIVER and not pass it in the query arguments, it will default to CITIZEN.

Reproduction Have the previous resolver with the user role defaulting to CITIZEN if nothing is passed in query arguments:

mutation {
  createDriver(
    data:{
      email:"testing@this.com"
      password:"1234567890"
    }
  ) {
    id
    email
    role
  }
}

The role argument is not passed because I want to explicit tell it what role in the resolver, but it doesn't seem to work. It will save the mutation with the default role written in the datamodel.graphql.

Expected behavior? If I explicit tell the resolver to create an user with the role DRIVER it should save the user with that role instead of defaulting to the one in datamodel.graphql.

marktani commented 6 years ago

I'm fairly sure this is a duplicate of https://github.com/graphcool/prisma-binding/issues/73.