guide icon indicating copy to clipboard operation
guide copied to clipboard

Put secretKey inside CreateUserInput?

Open lorensr opened this issue 5 years ago • 1 comments

We say it's best practice to use a single input type as an argument, and then we do this:

type Mutation {
  createUser(user: CreateUserInput!, secretKey: String!): User
}

I created it that way because secretKey felt like something out of band, like you'd put it in a header, except it's more convenient to be an argument given it's only used in this one resolver. Is that a good reason, in which case we could add an explanation, or should we just move it inside the input object like this?

input CreateUserInput {
  firstName: String!
  lastName: String!
  username: String!
  email: String!
  authId: String!
  secretKey: String!
}

Thanks to @Borales for asking

lorensr avatar May 09 '20 10:05 lorensr

@lorensr I wasn't quite sure about this question.

I don't think there's another way of creating a user without passing a secretKey. As an option - you could probably do something like:

type Mutation {
  createUser(input: CreateUserInput!): User
}

input CreateUserInput {
  user: CreateUserFieldsInput!
  secretKey: String!
}

input CreateUserFieldsInput {
  ... // user fields
}

Borales avatar May 09 '20 11:05 Borales