當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Angular2Apollo.mutate方法代碼示例

本文整理匯總了TypeScript中angular2-apollo.Angular2Apollo.mutate方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Angular2Apollo.mutate方法的具體用法?TypeScript Angular2Apollo.mutate怎麽用?TypeScript Angular2Apollo.mutate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在angular2-apollo.Angular2Apollo的用法示例。


在下文中一共展示了Angular2Apollo.mutate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: updateProfile

 updateProfile(firstName: string, lastName: string): Observable<ApolloQueryResult> {
   return  this.apollo
     .mutate({
       mutation: gql`
         mutation updateProfile(
           $firstName: String!
           $lastName: String!
         ) {
           updateProfile(
             firstName: $firstName
             lastName: $lastName
           ) {
             firstName
             lastName
           }
         }
       `,
       variables: {
         firstName,
         lastName
       },
     })
     .map(({ data }: ApolloQueryResult) => data.updateProfile)
     .catch(err => Observable.throw(err));
 }
開發者ID:correasebastian,項目名稱:apollo-chat,代碼行數:25,代碼來源:profile.service.ts

示例2: login

 /**
  * @param user Credentials for the user to login.
  * @returns A promise wrapping the result from the loginUser mutation.
  */
 login(user: IScapholdUserInput): Promise<GraphQLResult> {
     return this.client.mutate({
         mutation: gql`
             mutation LoginUser($input: _LoginUserInput!) {
                 loginUser(input: $input) {
                     id
                     token
                 }
             }
         `,
         variables: {
             input: {
                 username: user.username,
                 password: user.password
             }
         }
     }).then((result: GraphQLResult) => {
         const {data, errors} = result;
         if (errors) {
             throw errors;
         }
         this.setCredential(data['loginUser']);
         this.syncUser(data['loginUser']['id']);
         return result;
     });
 }
開發者ID:scaphold-io,項目名稱:angular2-apollo-client-webpack-starter,代碼行數:30,代碼來源:auth.service.ts

示例3: register

 /**
  * @param user Credentials for the new user.
  * @returns A promise wrapping the result from the createUser mutation.
  */
 register(user: IScapholdUserInput): Promise<GraphQLResult> {
     return this.client.mutate({
         mutation: gql`
             mutation CreateUser($input: _CreateUserInput!) {
                 createUser(input: $input) {
                     changedUser {
                         id
                         username
                         createdAt
                         modifiedAt
                         lastLogin
                     }
                 }
             }
         `,
         variables: {
             input: {
                 username: user.username,
                 password: user.password
             }
         }
     }).then((result: GraphQLResult) => {
         const {data, errors} = result;
         if (errors) {
             throw errors;
         }
         this.setUser(data['createUser']['changedUser']);
         return result;
     });
 }
開發者ID:scaphold-io,項目名稱:angular2-apollo-client-webpack-starter,代碼行數:34,代碼來源:auth.service.ts

示例4: newUser

  /**
   * Create new user with type player.
   * @param user The user.
   */
  public newUser(user: User): Observable<User> {
    const token = this.login.getToken();
    if (!token) {
      return Observable.throw("No authentication token");
    }

    if (!this.connectivityService.isOnline()) {
      this.storeForLaterPush(user);
      return Observable.from([user]);
    }
    return this.apollo
      .mutate({
        mutation: gql`
          mutation newUser($token: String!, $user: AutoUser!) {
            viewer(token: $token) {
              createAutoUser(user: $user) {
                _id
              }
            }
          }
        `,
        variables: {
          token,
          user,
        },
      }).map(result => {
        return result.data.viewer.createAutoUser as User;
      });
  }
開發者ID:racketometer,項目名稱:frontend-application,代碼行數:33,代碼來源:new-user.service.ts

示例5: submitForm

  public submitForm(): void {
    if (!this.repoFullName) {
      return;
    }

    this.error = null;

    this.apollo.mutate({
      mutation: submitRepositoryMutation,
      variables: {
        repoFullName: this.repoFullName,
      },
    }).then(() => {
      this.router.navigate(['/feed/new']);
    }).catch((error) => {
      this.error = error.message;
    });
  }
開發者ID:Tallyb,項目名稱:GitHunt-angular2,代碼行數:18,代碼來源:new-entry.component.ts

示例6: executeMutation

 executeMutation(argValues) {
   this.apolloClient.mutate(this.graphQLBuilder().buildMutation(argValues)).then(({data}) => {
     this.mutationResults = data[this.graphQLBuilder().queryName()];
   });
 }
開發者ID:gaslight,項目名稱:graphql-admin,代碼行數:5,代碼來源:gql-mutation.ts


注:本文中的angular2-apollo.Angular2Apollo.mutate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。