Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | import { UserType } from 'aws-sdk/clients/cognitoidentityserviceprovider'; import { GraphQLNonNull, GraphQLString } from 'graphql'; import errorCodes from '../../../errorCodes'; import { Pool, UserPoolId } from '../../../index'; import GraphQLUserGroup from '../inputs/UserGroup'; import { setGroups } from '../lib/groups'; import GraphQLUser from '../outputs/User'; import { generateCreateUserParams } from './helpers'; export default { type: GraphQLUser, args: { username: { type: new GraphQLNonNull(GraphQLString), }, email: { type: new GraphQLNonNull(GraphQLString), }, role: { type: new GraphQLNonNull(GraphQLUserGroup), }, expirationDateTime: { type: GraphQLString, }, }, resolve: async ( _: any, { username, email, role, expirationDateTime }: any, { userDetails }: any, ): Promise<UserType | undefined> => { const params = generateCreateUserParams( username, email, UserPoolId, expirationDateTime, ); try { const createdUser = await Pool.adminCreateUser(params).promise(); await setGroups(username, [role]); return createdUser.User; } catch (error) { throw new Error(errorCodes(error)); } }, }; |