当前位置: 首页>>代码示例>>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;未经允许,请勿转载。