Skip to content

Commit

Permalink
feat: extend email identity verification mutation (#4124)
Browse files Browse the repository at this point in the history
* feat: add email to schema

* feat: add field descriptions

* feat: extend mutation params to include email

* fix: pass correct user_id argument

* feat: return fields for success response
  • Loading branch information
mc-jones authored Jun 9, 2022
1 parent 9a9c567 commit 9b85a8d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 4 deletions.
30 changes: 29 additions & 1 deletion _schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8806,17 +8806,40 @@ type IdentityVerificationEdge {
}

type IdentityVerificationEmail {
created_at(
format: String

# A tz database time zone, otherwise falls back to "X-TIMEZONE" header. See
# http://www.iana.org/time-zones,
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone: String
): String

# Email of the identity verification's owner
email: String

# A globally unique ID.
id: ID!

# A type-specific ID likely used as a database ID.
internalID: ID!

# Name of the identity verification's owner
name: String

# Identity verification lifecycle state
state: String!
updated_at(
format: String

# A tz database time zone, otherwise falls back to "X-TIMEZONE" header. See
# http://www.iana.org/time-zones,
# https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
timezone: String
): String

# User ID of the identity verification's owner
userID: String!
userID: String
}

type IdentityVerificationEmailMutationFailureType {
Expand Down Expand Up @@ -13748,6 +13771,11 @@ union SendFeedbackMutationType =

input SendIdentityVerificationEmailMutationInput {
clientMutationId: String

# The email for the user undergoing identity verificaiton
email: String

# The user Id for the user undergoing identity verificaiton
userID: String
}

Expand Down
24 changes: 21 additions & 3 deletions src/schema/v2/me/sendIdentityVerficationEmailMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
formatGravityError,
} from "lib/gravityErrorHandler"
import { InternalIDFields } from "../object_identification"
import { date } from "../fields/date"

const IdentityVerificationEmailType = new GraphQLObjectType<
any,
Expand All @@ -19,13 +20,25 @@ const IdentityVerificationEmailType = new GraphQLObjectType<
name: "IdentityVerificationEmail",
fields: () => ({
...InternalIDFields,
created_at: date(({ created_at }) => created_at),
email: {
description: "Email of the identity verification's owner",
type: GraphQLString,
resolve: ({ email }) => email,
},
name: {
description: "Name of the identity verification's owner",
type: GraphQLString,
resolve: ({ name }) => name,
},
state: {
type: new GraphQLNonNull(GraphQLString),
description: "Identity verification lifecycle state",
},
updated_at: date(({ updated_at }) => updated_at),
userID: {
description: "User ID of the identity verification's owner",
type: new GraphQLNonNull(GraphQLString),
type: GraphQLString,
resolve: ({ user_id }) => user_id,
},
}),
Expand Down Expand Up @@ -78,6 +91,11 @@ export const sendIdentityVerificationEmailMutation = mutationWithClientMutationI
description: "Send a identity verification email",
inputFields: {
userID: {
description: "The user Id for the user undergoing identity verificaiton",
type: GraphQLString,
},
email: {
description: "The email for the user undergoing identity verificaiton",
type: GraphQLString,
},
},
Expand All @@ -88,14 +106,14 @@ export const sendIdentityVerificationEmailMutation = mutationWithClientMutationI
},
},
mutateAndGetPayload: (
{ userID },
{ userID, email },
{ sendIdentityVerificationEmailLoader }
) => {
if (!sendIdentityVerificationEmailLoader) {
throw new Error("You need to be signed in to perform this action")
}

return sendIdentityVerificationEmailLoader(userID)
return sendIdentityVerificationEmailLoader({ user_id: userID, email })
.then((result) => result)
.catch((error) => {
const formattedErr = formatGravityError(error)
Expand Down

0 comments on commit 9b85a8d

Please sign in to comment.