Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put secretKey inside CreateUserInput? #52

Open
lorensr opened this issue May 9, 2020 · 1 comment
Open

Put secretKey inside CreateUserInput? #52

lorensr opened this issue May 9, 2020 · 1 comment
Labels

Comments

@lorensr
Copy link
Member

lorensr commented May 9, 2020

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

@Borales
Copy link

Borales commented May 9, 2020

@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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants