12685af29a
* feat(useremails): userEmails graphql query * feat(useremails): create user email mutation * feat(useremails): set primary and delete user email mutations * chore(useremails): fix update user email type * chore(useremails): create typed tests for graphql and emails field resolver in user type * chore(userEmails): group user email mutations in a specific mutation object * linting fixes * more lint fixes * tests fix * more test fixes * chore(userEmails): cleanup * chore(useremails): rely on knex trx for transaction handling * chore(useremails): fix checkemail not present --------- Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com> Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
69 lines
1.2 KiB
TypeScript
69 lines
1.2 KiB
TypeScript
import { gql } from 'apollo-server-express'
|
|
|
|
export const userWithEmailsFragment = gql`
|
|
fragment UserWithEmails on User {
|
|
id
|
|
name
|
|
createdAt
|
|
role
|
|
emails {
|
|
id
|
|
email
|
|
verified
|
|
primary
|
|
}
|
|
}
|
|
`
|
|
|
|
export const getActiveUserEmails = gql`
|
|
query GetActiveUserEmails {
|
|
activeUser {
|
|
...UserWithEmails
|
|
}
|
|
}
|
|
|
|
${userWithEmailsFragment}
|
|
`
|
|
|
|
export const createUserEmailQuery = gql`
|
|
mutation CreateUserEmail($input: CreateUserEmailInput!) {
|
|
activeUserMutations {
|
|
emailMutations {
|
|
create(input: $input) {
|
|
...UserWithEmails
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
${userWithEmailsFragment}
|
|
`
|
|
|
|
export const deleteUserEmailQuery = gql`
|
|
mutation DeleteUserEmail($input: DeleteUserEmailInput!) {
|
|
activeUserMutations {
|
|
emailMutations {
|
|
delete(input: $input) {
|
|
...UserWithEmails
|
|
}
|
|
}
|
|
}
|
|
|
|
${userWithEmailsFragment}
|
|
}
|
|
`
|
|
|
|
export const setPrimaryUserEmailQuery = gql`
|
|
mutation SetPrimaryUserEmail($input: SetPrimaryUserEmailInput!) {
|
|
activeUserMutations {
|
|
emailMutations {
|
|
setPrimary(input: $input) {
|
|
...UserWithEmails
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
${userWithEmailsFragment}
|
|
`
|