本文整理汇总了TypeScript中apollo-mantra.mutation函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mutation函数的具体用法?TypeScript mutation怎么用?TypeScript mutation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mutation函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: emailResetLink
function emailResetLink(dispatch: Function, email: string, callback: Function) {
const ed = errorDispatch(dispatch);
if (!isNotEmpty(ed, email) || !isEmail(ed, email)) {
if (callback) { callback(); }
return;
}
dispatch(mutation({
query: `mutation requestResetPassword($email: String!) {
requestResetPassword(email: $email)
}`,
variables: {
email
},
catchCallback: (error) => {
let err = error.message;
if (error.graphQLErrors) {
err = error.graphQLErrors[0];
}
if (err.message === 'User email does not exist') {
dispatch(actions.showError('accounts.error.emailNotFound'));
} else {
dispatch(actions.showError('accounts.error.unknownError'));
}
if (callback) { callback(); }
},
thenCallback: (data: any) => {
dispatch(actions.showInfo('accounts.messages.passwordResetEmailSent'));
if (callback) { callback(); }
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:34,代码来源:accounts.ts
示例2: resendVerification
function resendVerification(dispatch: Function, email: string, callback: Function) {
const ed = errorDispatch(dispatch);
if (!isNotEmpty(ed, email) || !isEmail(ed, email)) {
if (callback) { callback(); }
return;
}
dispatch(mutation({
query: `mutation requestResendVerification($email: String!) {
requestResendVerification(email: $email)
}`,
variables: {
email
},
errorCallback: (err) => {
if (err.message === 'User not found') {
dispatch(actions.showError('accounts.error.emailNotFound'));
} if (err.message === 'User already verified') {
dispatch(actions.showError('accounts.error.userAlreadyVerified'));
} else {
dispatch(actions.showError('accounts.error.unknownError'));
}
if (callback) { callback(); }
},
thenCallback: (data: any) => {
dispatch(actions.showInfo('accounts.messages.verificationEmailSent'));
if (callback) { callback(); }
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:31,代码来源:accounts.ts
示例3: resume
function resume(dispatch: Function, token: string, tokenExpiration: number, profileData: string) {
if (new Date().getTime() > tokenExpiration) {
dispatch(actions.logOut());
return;
}
dispatch(actions.changeLoggingIn(true));
dispatch(mutation({
query: `mutation resume($token: String!) {
resume(token: $token) {
hashedToken
expires
user {
_id
profile {
${profileData}
}
roles
}
}
}`,
variables: {
token
},
catchCallback: (error) => {
dispatch(actions.changeLoggingIn(false));
dispatch(actions.logOut());
},
thenCallback: (data: any) => {
dispatch(actions.changeLoggingIn(false));
dispatch(actions.logIn(data.resume));
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:35,代码来源:accounts.ts
示例4: resetPassword
function resetPassword(dispatch: Function, token: string, password: string, passwordConfirm: string, profileData: string, callback: Function): void {
const ed = errorDispatch(dispatch);
if (!isNotEmpty(ed, password) || !areValidPasswords(ed, password, passwordConfirm)) {
return;
}
dispatch(mutation({
query: `mutation resetPassword($token: String!, $password: String!) {
resetPassword(token: $token, password: $password) {
hashedToken
expires
user {
_id
profile {
${profileData}
}
roles
}
}
}`,
variables: {
token,
password
},
catchCallback: (error) => {
let err = error;
if (error.graphQLErrors) {
err = error.graphQLErrors[0];
}
if (err.message === 'jwt expired') {
ed('accounts.error.tokenExpired');
} else if (err.message === 'invalid token') {
ed('accounts.error.invalidToken');
} else if (err.message === 'jwt malformed') {
ed('accounts.error.invalidToken');
} else {
ed(err.message);
}
if (callback) { callback(); }
},
thenCallback: (data: any) => {
// dispatch(actions.showInfo('accounts.messages.passwordChanged'));
const url = location.href.split('?')[0];
if (history && history.pushState) {
history.pushState(null, '', url);
dispatch(actions.logIn(data.resetPassword));
} else {
dispatch(actions.logIn(data.resetPassword));
window.location.href = url;
}
if (callback) { callback(); }
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:56,代码来源:accounts.ts
示例5: register
function register(dispatch: Function, name: string, email: string, password: string, passwordConfirm: string, profileData: string, callback: any) {
const ed = errorDispatch(dispatch);
let user = {
email: email,
password: password,
profile: {
name: name
}
};
if (!isNotEmpty(ed, email) || !isNotEmpty(ed, password) || !isEmail(ed, email) || !areValidPasswords(ed, password, passwordConfirm)) {
return;
}
dispatch(mutation({
query: `mutation createAccountAndLogin($user: UserPasswordInput!) {
createAccountAndLogin(user: $user) {
hashedToken
expires
user {
_id
profile {
${profileData}
}
roles
}
}
}`,
variables: {
user,
password
},
catchCallback: (error) => {
let err = error.message;
if (error.graphQLErrors) {
err = error.graphQLErrors[0];
}
if (err.message === 'User with this email already exists!') {
ed('accounts.error.emailAlreadyExists');
} else if (err.message === 'Email doesn\'t match the criteria.') {
ed('accounts.error.emailLimited');
} else if (err.message === 'Login forbidden') {
ed('accounts.error.loginForbidden');
} else {
ed('accounts.error.unknownError');
}
if (callback) { callback(); }
},
thenCallback: (data: any) => {
dispatch(actions.logIn(data.createAccountAndLogin));
if (callback) { callback(); }
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:55,代码来源:accounts.ts
示例6: signIn
function signIn(dispatch: Function, email: string, password: string, profileData: string, callback: Function): any {
dispatch(actions.clearMessages());
const ed = errorDispatch(dispatch);
email = trimInput(email.toLowerCase());
if (!isNotEmpty(ed, email) || !isEmail(ed, email) || !isNotEmpty(ed, password) || !isValidPassword(ed, password)) {
return;
}
dispatch(mutation({
query: `mutation loginWithPassword($user: UserPasswordInput!) {
loginWithPassword(user: $user) {
hashedToken
expires
user {
_id
profile {
${profileData}
}
roles
}
}
}`,
variables: {
user: {
email,
password
}
},
catchCallback: (error) => {
let err = error.message;
if (error.graphQLErrors) {
err = error.graphQLErrors[0];
}
if (err.message === 'Email not verified') {
dispatch(actions.showError('accounts.error.emailNotVerified'));
} else {
dispatch(actions.showError('accounts.error.invalidCredentials'));
}
if (callback) { callback(); }
},
// errorCallback: (err) => {
// dispatch(actions.showError('accounts.error.invalidCredentials'));
// if (callback) { callback(); }
// },
thenCallback: (data: any) => {
dispatch(actions.logIn(data.loginWithPassword));
if (callback) { callback(); }
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:54,代码来源:accounts.ts
示例7: verify
function verify(dispatch: Function, token: string, profileData: string): void {
const ed = errorDispatch(dispatch);
dispatch(mutation({
query: `mutation verify($token: String!) {
verify(token: $token) {
hashedToken
expires
user {
_id
profile {
${profileData}
}
roles
}
}
}`,
variables: {
token
},
catchCallback: (error) => {
let err = error.message;
if (error.graphQLErrors) {
err = error.graphQLErrors[0];
}
if (err.message === 'jwt expired') {
ed('accounts.error.tokenExpired');
} else if (err.message === 'invalid token') {
ed('accounts.error.invalidToken');
} else if (err.message === 'jwt malformed') {
ed('accounts.error.invalidToken');
} else {
ed(err.message);
}
},
thenCallback: (data: any) => {
const url = location.href.split('?')[0];
dispatch(actions.logIn(data.verify));
if (history && history.pushState) {
history.pushState(null, '', url);
} else {
window.location.href = url;
}
}
}));
}
开发者ID:tomitrescak,项目名称:meteor-accounts-ui-redux-semantic,代码行数:48,代码来源:accounts.ts
注:本文中的apollo-mantra.mutation函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论